diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index 6e42db82..20a13535 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -8,14 +8,13 @@ import { theme } from './theme.js' export default defineUserConfig({ base: '/', lang: 'zh-CN', - title: 'Plume Theme', - description: '', source: path.resolve(__dirname, '../'), public: path.resolve(__dirname, 'public'), locales: { '/': { title: 'Plume主题', description: '', lang: 'zh-CN' }, - '/en/': { title: 'Plume Theme', description: '', lang: 'en' }, + '/en/': { title: 'Plume Theme', description: '', lang: 'en-US' }, }, bundler: process.env.DOCS_BUNDLER === 'webpack' ? webpackBundler() : viteBundler(), + theme, }) diff --git a/docs/.vuepress/theme.ts b/docs/.vuepress/theme.ts index cd2552ec..2ffb6d21 100644 --- a/docs/.vuepress/theme.ts +++ b/docs/.vuepress/theme.ts @@ -7,9 +7,6 @@ export const theme = themePlume({ hostname: 'https://pengzhanbo.cn', repo: 'https://github.com/pengzhanbo/vuepress-theme-plume', docsDir: 'docs', - editLink: true, - editLinkText: '在 GitHub 编辑此页', - appearance: true, avatar: { url: '/images/blogger.jpg', name: 'Plume Theme', @@ -20,30 +17,19 @@ export const theme = themePlume({ locales: { '/': { - selectLanguageName: '简体中文', - selectLanguageText: '选择语言', notes: zhNotes, navbar: zhNavbar, }, '/en/': { - selectLanguageName: 'English', - selectLanguageText: 'Language', - editLinkText: 'Edit this page on GitHub', notes: enNotes, navbar: enNavbar, }, }, plugins: { - markdownEnhance: { katex: true }, - search: { - locales: { - '/': { - placeholder: '搜索', - }, - '/en/': { - placeholder: 'Search', - }, - }, - }, + // docsearch: { + // apiKey: '111', + // appId: '111', + // indexName: '1234', + // }, }, }) diff --git a/docs/package.json b/docs/package.json index 560048c0..cef23876 100644 --- a/docs/package.json +++ b/docs/package.json @@ -15,8 +15,6 @@ "@vuepress/client": "2.0.0-rc.0", "@vuepress/utils": "2.0.0-rc.0", "anywhere": "^1.6.0", - "katex": "^0.16.9", - "leancloud-storage": "^4.15.2", "sass": "^1.69.7", "sass-loader": "^13.3.3", "vue": "^3.4.5", diff --git a/package.json b/package.json index b4240476..f79a8cfc 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "taze": "^0.13.1", "tsconfig-vuepress": "^4.5.0", "typescript": "^5.3.3", - "vite": "^5.0.10" + "vite": "^5.0.11" }, "pnpm": { "peerDependencyRules": { diff --git a/plugins/plugin-netlify-functions/package.json b/plugins/plugin-netlify-functions/package.json index eaf91eba..2ca4b3c5 100644 --- a/plugins/plugin-netlify-functions/package.json +++ b/plugins/plugin-netlify-functions/package.json @@ -51,7 +51,7 @@ "dotenv": "^16.3.1", "esbuild": "^0.19.11", "execa": "^8.0.1", - "netlify-cli": "^17.11.0", + "netlify-cli": "^17.11.1", "portfinder": "^1.0.32" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b550f5f7..5ab7ae13 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,7 +16,7 @@ importers: version: 18.4.4 '@pengzhanbo/eslint-config-vue': specifier: ^1.5.1 - version: 1.5.1(@vue/compiler-sfc@3.4.3)(eslint-plugin-format@0.1.0)(eslint@8.56.0)(typescript@5.3.3) + version: 1.5.1(@vue/compiler-sfc@3.4.5)(eslint-plugin-format@0.1.0)(eslint@8.56.0)(typescript@5.3.3) '@types/minimist': specifier: ^1.2.5 version: 1.2.5 @@ -34,7 +34,7 @@ importers: version: 5.3.0 commitizen: specifier: ^4.3.0 - version: 4.3.0(typescript@5.3.3) + version: 4.3.0(@types/node@20.9.1)(typescript@5.3.3) concurrently: specifier: ^8.2.2 version: 8.2.2 @@ -49,7 +49,7 @@ importers: version: 7.0.3 cz-conventional-changelog: specifier: ^3.3.0 - version: 3.3.0(typescript@5.3.3) + version: 3.3.0(@types/node@20.9.1)(typescript@5.3.3) eslint: specifier: ^8.56.0 version: 8.56.0 @@ -93,8 +93,8 @@ importers: specifier: ^5.3.3 version: 5.3.3 vite: - specifier: ^5.0.10 - version: 5.0.10(@types/node@20.9.1)(sass@1.69.7) + specifier: ^5.0.11 + version: 5.0.11(@types/node@20.9.1)(sass@1.69.7) docs: dependencies: @@ -103,7 +103,7 @@ importers: version: 2.0.0-rc.0(@types/node@20.9.1)(sass@1.69.7)(typescript@5.3.3) '@vuepress/bundler-webpack': specifier: 2.0.0-rc.0 - version: 2.0.0-rc.0(@vue/compiler-sfc@3.4.3)(typescript@5.3.3) + version: 2.0.0-rc.0(@vue/compiler-sfc@3.4.5)(typescript@5.3.3) '@vuepress/cli': specifier: 2.0.0-rc.0 version: 2.0.0-rc.0(typescript@5.3.3) @@ -116,12 +116,6 @@ importers: anywhere: specifier: ^1.6.0 version: 1.6.0 - katex: - specifier: ^0.16.9 - version: 0.16.9 - leancloud-storage: - specifier: ^4.15.2 - version: 4.15.2 sass: specifier: ^1.69.7 version: 1.69.7 @@ -304,8 +298,8 @@ importers: specifier: ^8.0.1 version: 8.0.1 netlify-cli: - specifier: ^17.11.0 - version: 17.11.0(@types/node@20.10.6) + specifier: ^17.11.1 + version: 17.11.1(@types/node@20.10.6) portfinder: specifier: ^1.0.32 version: 1.0.32 @@ -473,8 +467,8 @@ importers: specifier: ^10.7.1 version: 10.7.1(vue@3.4.5) date-fns: - specifier: ^3.0.6 - version: 3.0.6 + specifier: ^3.1.0 + version: 3.1.0 katex: specifier: ^0.16.9 version: 0.16.9 @@ -676,13 +670,6 @@ packages: '@babel/highlight': 7.22.20 chalk: 2.4.2 - /@babel/code-frame@7.22.5: - resolution: {integrity: sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.22.5 - dev: true - /@babel/helper-string-parser@7.23.4: resolution: {integrity: sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==} engines: {node: '>=6.9.0'} @@ -691,11 +678,6 @@ packages: resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} engines: {node: '>=6.9.0'} - /@babel/helper-validator-identifier@7.22.5: - resolution: {integrity: sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==} - engines: {node: '>=6.9.0'} - dev: true - /@babel/highlight@7.22.20: resolution: {integrity: sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==} engines: {node: '>=6.9.0'} @@ -704,15 +686,6 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 - /@babel/highlight@7.22.5: - resolution: {integrity: sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-validator-identifier': 7.22.5 - chalk: 2.4.2 - js-tokens: 4.0.0 - dev: true - /@babel/parser@7.23.6: resolution: {integrity: sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==} engines: {node: '>=6.0.0'} @@ -825,16 +798,6 @@ packages: conventional-changelog-conventionalcommits: 7.0.2 dev: true - /@commitlint/config-validator@18.4.3: - resolution: {integrity: sha512-FPZZmTJBARPCyef9ohRC9EANiQEKSWIdatx5OlgeHKu878dWwpyeFauVkhzuBRJFcCA4Uvz/FDtlDKs008IHcA==} - engines: {node: '>=v18'} - requiresBuild: true - dependencies: - '@commitlint/types': 18.4.3 - ajv: 8.12.0 - dev: true - optional: true - /@commitlint/config-validator@18.4.4: resolution: {integrity: sha512-/QI8KIg/h7O0Eus36fPcEcO3QPBcdXuGfZeCF5m15k0EB2bcU8s6pHNTNEa6xz9PrAefHCL+yzRJj7w20T6Mow==} engines: {node: '>=v18'} @@ -855,13 +818,6 @@ packages: lodash.upperfirst: 4.3.1 dev: true - /@commitlint/execute-rule@18.4.3: - resolution: {integrity: sha512-t7FM4c+BdX9WWZCPrrbV5+0SWLgT3kCq7e7/GhHCreYifg3V8qyvO127HF796vyFql75n4TFF+5v1asOOWkV1Q==} - engines: {node: '>=v18'} - requiresBuild: true - dev: true - optional: true - /@commitlint/execute-rule@18.4.4: resolution: {integrity: sha512-a37Nd3bDQydtg9PCLLWM9ZC+GO7X5i4zJvrggJv5jBhaHsXeQ9ZWdO6ODYR+f0LxBXXNYK3geYXJrCWUCP8JEg==} engines: {node: '>=v18'} @@ -893,28 +849,6 @@ packages: '@commitlint/types': 18.4.4 dev: true - /@commitlint/load@18.4.3(typescript@5.3.3): - resolution: {integrity: sha512-v6j2WhvRQJrcJaj5D+EyES2WKTxPpxENmNpNG3Ww8MZGik3jWRXtph0QTzia5ZJyPh2ib5aC/6BIDymkUUM58Q==} - engines: {node: '>=v18'} - requiresBuild: true - dependencies: - '@commitlint/config-validator': 18.4.3 - '@commitlint/execute-rule': 18.4.3 - '@commitlint/resolve-extends': 18.4.3 - '@commitlint/types': 18.4.3 - '@types/node': 18.18.9 - chalk: 4.1.2 - cosmiconfig: 8.3.6(typescript@5.3.3) - cosmiconfig-typescript-loader: 5.0.0(@types/node@18.18.9)(cosmiconfig@8.3.6)(typescript@5.3.3) - lodash.isplainobject: 4.0.6 - lodash.merge: 4.6.2 - lodash.uniq: 4.5.0 - resolve-from: 5.0.0 - transitivePeerDependencies: - - typescript - dev: true - optional: true - /@commitlint/load@18.4.4(@types/node@20.9.1)(typescript@5.3.3): resolution: {integrity: sha512-RaDIa9qwOw2xRJ3Jr2DBXd14rmnHJIX2XdZF4kmoF1rgsg/+7cvrExLSUNAkQUNimyjCn1b/bKX2Omm+GdY0XQ==} engines: {node: '>=v18'} @@ -959,20 +893,6 @@ packages: minimist: 1.2.8 dev: true - /@commitlint/resolve-extends@18.4.3: - resolution: {integrity: sha512-30sk04LZWf8+SDgJrbJCjM90gTg2LxsD9cykCFeFu+JFHvBFq5ugzp2eO/DJGylAdVaqxej3c7eTSE64hR/lnw==} - engines: {node: '>=v18'} - requiresBuild: true - dependencies: - '@commitlint/config-validator': 18.4.3 - '@commitlint/types': 18.4.3 - import-fresh: 3.3.0 - lodash.mergewith: 4.6.2 - resolve-from: 5.0.0 - resolve-global: 1.0.0 - dev: true - optional: true - /@commitlint/resolve-extends@18.4.4: resolution: {integrity: sha512-RRpIHSbRnFvmGifVk21Gqazf1QF/yeP+Kkg/e3PlkegcOKd/FGOXp/Kx9cvSO2K7ucSn4GD/oBvgasFoy+NCAw==} engines: {node: '>=v18'} @@ -1008,15 +928,6 @@ packages: find-up: 5.0.0 dev: true - /@commitlint/types@18.4.3: - resolution: {integrity: sha512-cvzx+vtY/I2hVBZHCLrpoh+sA0hfuzHwDc+BAFPimYLjJkpHnghQM+z8W/KyLGkygJh3BtI3xXXq+dKjnSWEmA==} - engines: {node: '>=v18'} - requiresBuild: true - dependencies: - chalk: 4.1.2 - dev: true - optional: true - /@commitlint/types@18.4.4: resolution: {integrity: sha512-/FykLtodD8gKs3+VNkAUwofu4LBHankclj+I8fB2jTRvG6PV7k/OUt4P+VbM7ip853qS4F0g7Z6hLNa6JeMcAQ==} engines: {node: '>=v18'} @@ -1117,6 +1028,7 @@ packages: cpu: [ppc64] os: [aix] requiresBuild: true + dev: false optional: true /@esbuild/aix-ppc64@0.19.11: @@ -1125,7 +1037,6 @@ packages: cpu: [ppc64] os: [aix] requiresBuild: true - dev: false optional: true /@esbuild/android-arm64@0.19.10: @@ -1134,6 +1045,7 @@ packages: cpu: [arm64] os: [android] requiresBuild: true + dev: false optional: true /@esbuild/android-arm64@0.19.11: @@ -1142,7 +1054,6 @@ packages: cpu: [arm64] os: [android] requiresBuild: true - dev: false optional: true /@esbuild/android-arm64@0.19.6: @@ -1169,6 +1080,7 @@ packages: cpu: [arm] os: [android] requiresBuild: true + dev: false optional: true /@esbuild/android-arm@0.19.11: @@ -1177,7 +1089,6 @@ packages: cpu: [arm] os: [android] requiresBuild: true - dev: false optional: true /@esbuild/android-arm@0.19.6: @@ -1204,6 +1115,7 @@ packages: cpu: [x64] os: [android] requiresBuild: true + dev: false optional: true /@esbuild/android-x64@0.19.11: @@ -1212,7 +1124,6 @@ packages: cpu: [x64] os: [android] requiresBuild: true - dev: false optional: true /@esbuild/android-x64@0.19.6: @@ -1239,6 +1150,7 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true + dev: false optional: true /@esbuild/darwin-arm64@0.19.11: @@ -1247,7 +1159,6 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true - dev: false optional: true /@esbuild/darwin-arm64@0.19.6: @@ -1274,6 +1185,7 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true + dev: false optional: true /@esbuild/darwin-x64@0.19.11: @@ -1282,7 +1194,6 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true - dev: false optional: true /@esbuild/darwin-x64@0.19.6: @@ -1309,6 +1220,7 @@ packages: cpu: [arm64] os: [freebsd] requiresBuild: true + dev: false optional: true /@esbuild/freebsd-arm64@0.19.11: @@ -1317,7 +1229,6 @@ packages: cpu: [arm64] os: [freebsd] requiresBuild: true - dev: false optional: true /@esbuild/freebsd-arm64@0.19.6: @@ -1344,6 +1255,7 @@ packages: cpu: [x64] os: [freebsd] requiresBuild: true + dev: false optional: true /@esbuild/freebsd-x64@0.19.11: @@ -1352,7 +1264,6 @@ packages: cpu: [x64] os: [freebsd] requiresBuild: true - dev: false optional: true /@esbuild/freebsd-x64@0.19.6: @@ -1379,6 +1290,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-arm64@0.19.11: @@ -1387,7 +1299,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-arm64@0.19.6: @@ -1414,6 +1325,7 @@ packages: cpu: [arm] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-arm@0.19.11: @@ -1422,7 +1334,6 @@ packages: cpu: [arm] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-arm@0.19.6: @@ -1449,6 +1360,7 @@ packages: cpu: [ia32] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-ia32@0.19.11: @@ -1457,7 +1369,6 @@ packages: cpu: [ia32] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-ia32@0.19.6: @@ -1484,6 +1395,7 @@ packages: cpu: [loong64] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-loong64@0.19.11: @@ -1492,7 +1404,6 @@ packages: cpu: [loong64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-loong64@0.19.6: @@ -1519,6 +1430,7 @@ packages: cpu: [mips64el] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-mips64el@0.19.11: @@ -1527,7 +1439,6 @@ packages: cpu: [mips64el] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-mips64el@0.19.6: @@ -1554,6 +1465,7 @@ packages: cpu: [ppc64] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-ppc64@0.19.11: @@ -1562,7 +1474,6 @@ packages: cpu: [ppc64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-ppc64@0.19.6: @@ -1589,6 +1500,7 @@ packages: cpu: [riscv64] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-riscv64@0.19.11: @@ -1597,7 +1509,6 @@ packages: cpu: [riscv64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-riscv64@0.19.6: @@ -1624,6 +1535,7 @@ packages: cpu: [s390x] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-s390x@0.19.11: @@ -1632,7 +1544,6 @@ packages: cpu: [s390x] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-s390x@0.19.6: @@ -1659,6 +1570,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: false optional: true /@esbuild/linux-x64@0.19.11: @@ -1667,7 +1579,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-x64@0.19.6: @@ -1694,6 +1605,7 @@ packages: cpu: [x64] os: [netbsd] requiresBuild: true + dev: false optional: true /@esbuild/netbsd-x64@0.19.11: @@ -1702,7 +1614,6 @@ packages: cpu: [x64] os: [netbsd] requiresBuild: true - dev: false optional: true /@esbuild/netbsd-x64@0.19.6: @@ -1729,6 +1640,7 @@ packages: cpu: [x64] os: [openbsd] requiresBuild: true + dev: false optional: true /@esbuild/openbsd-x64@0.19.11: @@ -1737,7 +1649,6 @@ packages: cpu: [x64] os: [openbsd] requiresBuild: true - dev: false optional: true /@esbuild/openbsd-x64@0.19.6: @@ -1764,6 +1675,7 @@ packages: cpu: [x64] os: [sunos] requiresBuild: true + dev: false optional: true /@esbuild/sunos-x64@0.19.11: @@ -1772,7 +1684,6 @@ packages: cpu: [x64] os: [sunos] requiresBuild: true - dev: false optional: true /@esbuild/sunos-x64@0.19.6: @@ -1799,6 +1710,7 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true + dev: false optional: true /@esbuild/win32-arm64@0.19.11: @@ -1807,7 +1719,6 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true - dev: false optional: true /@esbuild/win32-arm64@0.19.6: @@ -1834,6 +1745,7 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true + dev: false optional: true /@esbuild/win32-ia32@0.19.11: @@ -1842,7 +1754,6 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true - dev: false optional: true /@esbuild/win32-ia32@0.19.6: @@ -1869,6 +1780,7 @@ packages: cpu: [x64] os: [win32] requiresBuild: true + dev: false optional: true /@esbuild/win32-x64@0.19.11: @@ -1877,7 +1789,6 @@ packages: cpu: [x64] os: [win32] requiresBuild: true - dev: false optional: true /@esbuild/win32-x64@0.19.6: @@ -4032,7 +3943,7 @@ packages: '@parcel/watcher-win32-x64': 2.3.0 dev: false - /@pengzhanbo/eslint-config-vue@1.5.1(@vue/compiler-sfc@3.4.3)(eslint-plugin-format@0.1.0)(eslint@8.56.0)(typescript@5.3.3): + /@pengzhanbo/eslint-config-vue@1.5.1(@vue/compiler-sfc@3.4.5)(eslint-plugin-format@0.1.0)(eslint@8.56.0)(typescript@5.3.3): resolution: {integrity: sha512-4+ERArSMd5ovP0etk1BcH/chIB7Z/JvG/LoBErTn9Xujdj+g9ANyCJA/JNxMRh88DbMmCRp2ho1+4/b82HTipw==} peerDependencies: '@unocss/eslint-plugin': '>=0.50.0' @@ -4049,7 +3960,7 @@ packages: eslint: 8.56.0 eslint-merge-processors: 0.1.0(eslint@8.56.0) eslint-plugin-vue: 9.19.2(eslint@8.56.0) - eslint-processor-vue-blocks: 0.1.1(@vue/compiler-sfc@3.4.3)(eslint@8.56.0) + eslint-processor-vue-blocks: 0.1.1(@vue/compiler-sfc@3.4.5)(eslint@8.56.0) vue-eslint-parser: 9.3.2(eslint@8.56.0) transitivePeerDependencies: - '@vue/compiler-sfc' @@ -4646,14 +4557,6 @@ packages: resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} dev: false - /@types/node@18.18.9: - resolution: {integrity: sha512-0f5klcuImLnG4Qreu9hPj/rEfFq6YRc5n2mAjSsH+ec/mJL+3voBH0+8T7o8RpFjH7ovc+TRsL/c7OYIQsPTfQ==} - requiresBuild: true - dependencies: - undici-types: 5.26.5 - dev: true - optional: true - /@types/node@20.10.6: resolution: {integrity: sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==} dependencies: @@ -4977,26 +4880,17 @@ packages: - supports-color dev: false - /@vitejs/plugin-vue@4.5.0(vite@5.0.10)(vue@3.4.5): + /@vitejs/plugin-vue@4.5.0(vite@5.0.11)(vue@3.4.5): resolution: {integrity: sha512-a2WSpP8X8HTEww/U00bU4mX1QpLINNuz/2KMNpLsdu3BzOpak3AGI1CJYBTXcc4SPhaD0eNRUp7IyQK405L5dQ==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: vite: ^4.0.0 || ^5.0.0 vue: ^3.2.25 dependencies: - vite: 5.0.10(@types/node@20.9.1)(sass@1.69.7) + vite: 5.0.11(@types/node@20.9.1)(sass@1.69.7) vue: 3.4.5(typescript@5.3.3) dev: false - /@vue/compiler-core@3.4.3: - resolution: {integrity: sha512-u8jzgFg0EDtSrb/hG53Wwh1bAOQFtc1ZCegBpA/glyvTlgHl+tq13o1zvRfLbegYUw/E4mSTGOiCnAJ9SJ+lsg==} - dependencies: - '@babel/parser': 7.23.6 - '@vue/shared': 3.4.3 - entities: 4.5.0 - estree-walker: 2.0.2 - source-map-js: 1.0.2 - /@vue/compiler-core@3.4.5: resolution: {integrity: sha512-Daka7P1z2AgKjzuueWXhwzIsKu0NkLB6vGbNVEV2iJ8GJTrzraZo/Sk4GWCMRtd/qVi3zwnk+Owbd/xSZbwHtQ==} dependencies: @@ -5005,33 +4899,12 @@ packages: entities: 4.5.0 estree-walker: 2.0.2 source-map-js: 1.0.2 - dev: false - - /@vue/compiler-dom@3.4.3: - resolution: {integrity: sha512-oGF1E9/htI6JWj/lTJgr6UgxNCtNHbM6xKVreBWeZL9QhRGABRVoWGAzxmtBfSOd+w0Zi5BY0Es/tlJrN6WgEg==} - dependencies: - '@vue/compiler-core': 3.4.3 - '@vue/shared': 3.4.3 /@vue/compiler-dom@3.4.5: resolution: {integrity: sha512-J8YlxknJVd90SXFJ4HwGANSAXsx5I0lK30sO/zvYV7s5gXf7gZR7r/1BmZ2ju7RGH1lnc6bpBc6nL61yW+PsAQ==} dependencies: '@vue/compiler-core': 3.4.5 '@vue/shared': 3.4.5 - dev: false - - /@vue/compiler-sfc@3.4.3: - resolution: {integrity: sha512-NuJqb5is9I4uzv316VRUDYgIlPZCG8D+ARt5P4t5UDShIHKL25J3TGZAUryY/Aiy0DsY7srJnZL5ryB6DD63Zw==} - dependencies: - '@babel/parser': 7.23.6 - '@vue/compiler-core': 3.4.3 - '@vue/compiler-dom': 3.4.3 - '@vue/compiler-ssr': 3.4.3 - '@vue/shared': 3.4.3 - estree-walker: 2.0.2 - magic-string: 0.30.5 - postcss: 8.4.32 - source-map-js: 1.0.2 /@vue/compiler-sfc@3.4.5: resolution: {integrity: sha512-jauvkDuSSUbP0ebhfNqljhShA90YEfX/0wZ+w40oZF43IjGyWYjqYaJbvMJwGOd+9+vODW6eSvnk28f0SGV7OQ==} @@ -5045,20 +4918,12 @@ packages: magic-string: 0.30.5 postcss: 8.4.32 source-map-js: 1.0.2 - dev: false - - /@vue/compiler-ssr@3.4.3: - resolution: {integrity: sha512-wnYQtMBkeFSxgSSQbYGQeXPhQacQiog2c6AlvMldQH6DB+gSXK/0F6DVXAJfEiuBSgBhUc8dwrrG5JQcqwalsA==} - dependencies: - '@vue/compiler-dom': 3.4.3 - '@vue/shared': 3.4.3 /@vue/compiler-ssr@3.4.5: resolution: {integrity: sha512-DDdEcDzj2lWTMfUMMtEpLDhURai9LhM0zSZ219jCt7b2Vyl0/jy3keFgCPMitG0V1S1YG4Cmws3lWHWdxHQOpg==} dependencies: '@vue/compiler-dom': 3.4.5 '@vue/shared': 3.4.5 - dev: false /@vue/devtools-api@6.5.1: resolution: {integrity: sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA==} @@ -5099,17 +4964,13 @@ packages: resolution: {integrity: sha512-/zYUwiHD8j7gKx2argXEMCUXVST6q/21DFU0sTfNX0URJroCe3b1UF6vLJ3lQDfLNIiiRl2ONp7Nh5UVWS6QnA==} dev: false - /@vue/shared@3.4.3: - resolution: {integrity: sha512-rIwlkkP1n4uKrRzivAKPZIEkHiuwY5mmhMJ2nZKCBLz8lTUlE73rQh4n1OnnMurXt1vcUNyH4ZPfdh8QweTjpQ==} - /@vue/shared@3.4.5: resolution: {integrity: sha512-6XptuzlMvN4l4cDnDw36pdGEV+9njYkQ1ZE0Q6iZLwrKefKaOJyiFmcP3/KBDHbt72cJZGtllAc1GaHe6XGAyg==} - dev: false /@vuepress/bundler-vite@2.0.0-rc.0(@types/node@20.9.1)(sass@1.69.7)(typescript@5.3.3): resolution: {integrity: sha512-rX8S8IYpqqlJfNPstS/joorpxXx/4WuE7+gDM31i2HUrxOKGZVzq8ZsRRRU2UdoTwHZSd3LpUS4sMtxE5xLK1A==} dependencies: - '@vitejs/plugin-vue': 4.5.0(vite@5.0.10)(vue@3.4.5) + '@vitejs/plugin-vue': 4.5.0(vite@5.0.11)(vue@3.4.5) '@vuepress/client': 2.0.0-rc.0(typescript@5.3.3) '@vuepress/core': 2.0.0-rc.0(typescript@5.3.3) '@vuepress/shared': 2.0.0-rc.0 @@ -5119,7 +4980,7 @@ packages: postcss: 8.4.31 postcss-load-config: 4.0.1(postcss@8.4.31) rollup: 4.4.1 - vite: 5.0.10(@types/node@20.9.1)(sass@1.69.7) + vite: 5.0.11(@types/node@20.9.1)(sass@1.69.7) vue: 3.4.5(typescript@5.3.3) vue-router: 4.2.5(vue@3.4.5) transitivePeerDependencies: @@ -5136,7 +4997,7 @@ packages: - typescript dev: false - /@vuepress/bundler-webpack@2.0.0-rc.0(@vue/compiler-sfc@3.4.3)(typescript@5.3.3): + /@vuepress/bundler-webpack@2.0.0-rc.0(@vue/compiler-sfc@3.4.5)(typescript@5.3.3): resolution: {integrity: sha512-PUbjaQCTE+pwkmHkozT4CCjdEiAEO89XOXKTO/VwEsv6hWNeT97fi7TnScV/x8R/9WeA45QrW3eHipMwkKJ8uQ==} dependencies: '@types/express': 4.17.21 @@ -5158,7 +5019,7 @@ packages: postcss-loader: 7.3.3(postcss@8.4.31)(webpack@5.89.0) style-loader: 3.3.3(webpack@5.89.0) vue: 3.4.5(typescript@5.3.3) - vue-loader: 17.3.1(@vue/compiler-sfc@3.4.3)(vue@3.4.5)(webpack@5.89.0) + vue-loader: 17.3.1(@vue/compiler-sfc@3.4.5)(vue@3.4.5)(webpack@5.89.0) vue-router: 4.2.5(vue@3.4.5) webpack: 5.89.0 webpack-chain: 6.5.1 @@ -7064,13 +6925,13 @@ packages: engines: {node: '>= 12.0.0'} dev: true - /commitizen@4.3.0(typescript@5.3.3): + /commitizen@4.3.0(@types/node@20.9.1)(typescript@5.3.3): resolution: {integrity: sha512-H0iNtClNEhT0fotHvGV3E9tDejDeS04sN1veIebsKYGMuGscFaswRoYJKmT3eW85eIJAs0F28bG2+a/9wCOfPw==} engines: {node: '>= 12'} hasBin: true dependencies: cachedir: 2.3.0 - cz-conventional-changelog: 3.3.0(typescript@5.3.3) + cz-conventional-changelog: 3.3.0(@types/node@20.9.1)(typescript@5.3.3) dedent: 0.7.0 detect-indent: 6.1.0 find-node-modules: 2.1.3 @@ -7084,6 +6945,7 @@ packages: strip-bom: 4.0.0 strip-json-comments: 3.1.1 transitivePeerDependencies: + - '@types/node' - typescript dev: true @@ -7588,22 +7450,6 @@ packages: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} dev: false - /cosmiconfig-typescript-loader@5.0.0(@types/node@18.18.9)(cosmiconfig@8.3.6)(typescript@5.3.3): - resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} - engines: {node: '>=v16'} - requiresBuild: true - peerDependencies: - '@types/node': '*' - cosmiconfig: '>=8.2' - typescript: '>=4' - dependencies: - '@types/node': 18.18.9 - cosmiconfig: 8.3.6(typescript@5.3.3) - jiti: 1.20.0 - typescript: 5.3.3 - dev: true - optional: true - /cosmiconfig-typescript-loader@5.0.0(@types/node@20.9.1)(cosmiconfig@8.3.6)(typescript@5.3.3): resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} engines: {node: '>=v16'} @@ -7837,19 +7683,20 @@ packages: resolution: {integrity: sha512-NJGVKPS81XejHcLhaLJS7plab0fK3slPh11mESeeDq2W4ZI5kUKK/LRRdVDvjJseojbPB7ZwjnyOybg3Igea/A==} dev: false - /cz-conventional-changelog@3.3.0(typescript@5.3.3): + /cz-conventional-changelog@3.3.0(@types/node@20.9.1)(typescript@5.3.3): resolution: {integrity: sha512-U466fIzU5U22eES5lTNiNbZ+d8dfcHcssH4o7QsdWaCcRs/feIPCxKYSWkYBNs5mny7MvEfwpTLWjvbm94hecw==} engines: {node: '>= 10'} dependencies: chalk: 2.4.2 - commitizen: 4.3.0(typescript@5.3.3) + commitizen: 4.3.0(@types/node@20.9.1)(typescript@5.3.3) conventional-commit-types: 3.0.0 lodash.map: 4.6.0 longest: 2.0.1 word-wrap: 1.2.3 optionalDependencies: - '@commitlint/load': 18.4.3(typescript@5.3.3) + '@commitlint/load': 18.4.4(@types/node@20.9.1)(typescript@5.3.3) transitivePeerDependencies: + - '@types/node' - typescript dev: true @@ -7874,8 +7721,8 @@ packages: '@babel/runtime': 7.21.5 dev: true - /date-fns@3.0.6: - resolution: {integrity: sha512-W+G99rycpKMMF2/YD064b2lE7jJGUe+EjOES7Q8BIGY8sbNdbgcs9XFTZwvzc9Jx1f3k7LB7gZaZa7f8Agzljg==} + /date-fns@3.1.0: + resolution: {integrity: sha512-ZO7yefXV/wCWzd3I9haCHmfzlfA3i1a2HHO7ZXjtJrRjXt8FULKJ2Vl8wji3XYF4dQ0ZJ/tokXDZeYlFvgms9Q==} dev: false /date-time@3.1.0: @@ -8475,6 +8322,7 @@ packages: '@esbuild/win32-arm64': 0.19.10 '@esbuild/win32-ia32': 0.19.10 '@esbuild/win32-x64': 0.19.10 + dev: false /esbuild@0.19.11: resolution: {integrity: sha512-HJ96Hev2hX/6i5cDVwcqiJBBtuo9+FeIJOtZ9W1kA5M6AMJRHUZlpYZ1/SbEwtO0ioNAW8rUooVpC/WehY2SfA==} @@ -8505,7 +8353,6 @@ packages: '@esbuild/win32-arm64': 0.19.11 '@esbuild/win32-ia32': 0.19.11 '@esbuild/win32-x64': 0.19.11 - dev: false /esbuild@0.19.6: resolution: {integrity: sha512-Xl7dntjA2OEIvpr9j0DVxxnog2fyTGnyVoQXAMQI6eR3mf9zCQds7VIKUDCotDgE/p4ncTgeRqgX8t5d6oP4Gw==} @@ -8962,13 +8809,13 @@ packages: - supports-color dev: true - /eslint-processor-vue-blocks@0.1.1(@vue/compiler-sfc@3.4.3)(eslint@8.56.0): + /eslint-processor-vue-blocks@0.1.1(@vue/compiler-sfc@3.4.5)(eslint@8.56.0): resolution: {integrity: sha512-9+dU5lU881log570oBwpelaJmOfOzSniben7IWEDRYQPPWwlvaV7NhOtsTuUWDqpYT+dtKKWPsgz4OkOi+aZnA==} peerDependencies: '@vue/compiler-sfc': ^3.3.0 eslint: ^8.50.0 dependencies: - '@vue/compiler-sfc': 3.4.3 + '@vue/compiler-sfc': 3.4.5 eslint: 8.56.0 dev: true @@ -10419,7 +10266,7 @@ packages: resolution: {integrity: sha512-+K84LB1DYwMHoHSgaOY/Jfhw3ucPmSET5v98Ke/HdNSw4a0UktWzyW1mjhjpuxxTqOOsfWT/7iVshHmVZ4IpOA==} engines: {node: ^16.14.0 || >=18.0.0} dependencies: - lru-cache: 10.0.1 + lru-cache: 10.0.2 dev: true /hot-shots@10.0.0: @@ -12696,8 +12543,8 @@ packages: resolution: {integrity: sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw==} dev: false - /netlify-cli@17.11.0(@types/node@20.10.6): - resolution: {integrity: sha512-EIdKpkc6yw9T3uPe7kuQSOa+fai0uCBPvXxRZNQkcJ8Wo0T8fwM+gBehH4tAyBk13RehppGklIcOsa+Ym1wMRg==} + /netlify-cli@17.11.1(@types/node@20.10.6): + resolution: {integrity: sha512-nkTPrxgMG1XL4JGgINCFyHHFw6/mw8oTaTc3VkzZNWB5mfFV2H0BZeLjNCviJo4yFOzDNIoKcIT59t0zgWy7HQ==} engines: {node: '>=18.14.0'} hasBin: true requiresBuild: true @@ -13680,7 +13527,7 @@ packages: resolution: {integrity: sha512-ihtdrgbqdONYD156Ap6qTcaGcGdkdAxodO1wLqQ/j7HP1u2sFYppINiq4jyC8F+Nm+4fVufylCV00QmkTHkSUg==} engines: {node: '>=16'} dependencies: - '@babel/code-frame': 7.22.5 + '@babel/code-frame': 7.22.13 error-ex: 1.3.2 json-parse-even-better-errors: 3.0.0 lines-and-columns: 2.0.3 @@ -16644,8 +16491,8 @@ packages: engines: {node: '>= 0.8'} dev: false - /vite@5.0.10(@types/node@20.9.1)(sass@1.69.7): - resolution: {integrity: sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==} + /vite@5.0.11(@types/node@20.9.1)(sass@1.69.7): + resolution: {integrity: sha512-XBMnDjZcNAw/G1gEiskiM1v6yzM4GE5aMGvhWTlHAYYhxb7S3/V1s3m2LDHa8Vh6yIWYYB0iJwsEaS523c4oYA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -16673,7 +16520,7 @@ packages: optional: true dependencies: '@types/node': 20.9.1 - esbuild: 0.19.10 + esbuild: 0.19.11 postcss: 8.4.32 rollup: 4.4.1 sass: 1.69.7 @@ -16713,7 +16560,7 @@ packages: - supports-color dev: true - /vue-loader@17.3.1(@vue/compiler-sfc@3.4.3)(vue@3.4.5)(webpack@5.89.0): + /vue-loader@17.3.1(@vue/compiler-sfc@3.4.5)(vue@3.4.5)(webpack@5.89.0): resolution: {integrity: sha512-nmVu7KU8geOyzsStyyaxID/uBGDMS8BkPXb6Lu2SNkMawriIbb+hYrNtgftHMKxOSkjjjTF5OSSwPo3KP59egg==} peerDependencies: '@vue/compiler-sfc': '*' @@ -16727,7 +16574,7 @@ packages: webpack: optional: true dependencies: - '@vue/compiler-sfc': 3.4.3 + '@vue/compiler-sfc': 3.4.5 chalk: 4.1.2 hash-sum: 2.0.0 vue: 3.4.5(typescript@5.3.3) diff --git a/readme.md b/readme.md index c2925c07..1b48de81 100644 --- a/readme.md +++ b/readme.md @@ -2,11 +2,11 @@ 一个简约的 vuepress 主题。 -开箱即用,仅需少量配置即可使用。 +开箱即用,仅需少量配置即可使用,让您更专注于 内容的创作。 [![npm version](https://img.shields.io/npm/v/vuepress-theme-plume?color=32A9C3&labelColor=1B3C4A&label=npm)](https://www.npmjs.com/package/vuepress-theme-plume) [![npm beta download](https://img.shields.io/npm/dt/@vuepress-plume/vuepress-theme-plume?color=32A9C3&labelColor=1B3C4A&label=beta%20downloads)](https://www.npmjs.com/package/vuepress-theme-plume) -[![npm download](https://img.shields.io/npm/dy/vuepress-theme-plume?color=32A9C3&labelColor=1B3C4A&label=downloads)](https://www.npmjs.com/package/vuepress-theme-plume) +[![npm download](https://img.shields.io/npm/dm/vuepress-theme-plume?color=32A9C3&labelColor=1B3C4A&label=downloads)](https://www.npmjs.com/package/vuepress-theme-plume) ![GitHub License](https://img.shields.io/github/license/pengzhanbo/vuepress-theme-plume?color=32A9C3&labelColor=1B3C4A) ### [查看文档](https://pengzhanbo.cn/note/vuepress-theme-plume) @@ -14,11 +14,11 @@ ## Install ``` sh -npm install vuepress@next vuepress-theme-plume +npm install vue vuepress@next vuepress-theme-plume # or -pnpm add vuepress@next vuepress-theme-plume +pnpm add vue vuepress@next vuepress-theme-plume # or -yarn add vuepress@next vuepress-theme-plume +yarn add vue vuepress@next vuepress-theme-plume ``` ## Usage @@ -28,8 +28,9 @@ import { defineUserConfig } from 'vuepress' import { plumeTheme } from 'vuepress-theme-plume' export default defineUserConfig({ + // vuepress config... theme: plumeTheme({ - // theme config + // theme config... }) }) ``` diff --git a/theme/package.json b/theme/package.json index 203e7a21..8e386da7 100644 --- a/theme/package.json +++ b/theme/package.json @@ -78,7 +78,7 @@ "@vuepress/shared": "2.0.0-rc.0", "@vuepress/utils": "2.0.0-rc.0", "@vueuse/core": "^10.7.1", - "date-fns": "^3.0.6", + "date-fns": "^3.1.0", "katex": "^0.16.9", "lodash.merge": "^4.6.2", "nanoid": "^5.0.4", diff --git a/theme/src/client/components/BlogAside.vue b/theme/src/client/components/BlogAside.vue index 6f50c300..a16de9b3 100644 --- a/theme/src/client/components/BlogAside.vue +++ b/theme/src/client/components/BlogAside.vue @@ -66,7 +66,7 @@ const { hasBlogExtract, tags, archives } = useBlogExtract() } .blog-nav { - padding: 10px 24px 0; + padding: 10px 12px 0; margin: 24px 24px 0; display: grid; gap: 16px; @@ -77,6 +77,7 @@ const { hasBlogExtract, tags, archives } = useBlogExtract() .nav-link { display: flex; align-items: center; + justify-content: center; padding: 3px; color: var(--vp-c-brand-1); font-weight: 600; diff --git a/theme/src/client/composables/langs.ts b/theme/src/client/composables/langs.ts index b1df741c..5130daca 100644 --- a/theme/src/client/composables/langs.ts +++ b/theme/src/client/composables/langs.ts @@ -1,4 +1,4 @@ -import { usePageData, usePageLang, useSiteData } from '@vuepress/client' +import { usePageData, useRouteLocale } from '@vuepress/client' import { computed } from 'vue' import type { PlumeThemePageData } from '../../shared/index.js' import { ensureStartingSlash } from '../utils/index.js' @@ -10,11 +10,10 @@ export function useLangs({ correspondingLink = false, } = {}) { const page = usePageData() - const site = useSiteData() const theme = useThemeData() - const locale = usePageLang() + const routeLocale = useRouteLocale() const currentLang = computed(() => { - const link = locale.value === site.value.lang ? '/' : `/${locale.value}/` + const link = routeLocale.value return { label: theme.value.locales?.[link]?.selectLanguageName, link, diff --git a/theme/src/client/layouts/NotFound.vue b/theme/src/client/layouts/NotFound.vue index 0be90c63..892794e3 100644 --- a/theme/src/client/layouts/NotFound.vue +++ b/theme/src/client/layouts/NotFound.vue @@ -1,11 +1,10 @@ diff --git a/theme/src/node/defaultOptions.ts b/theme/src/node/defaultOptions.ts index be3b3d20..9164b778 100644 --- a/theme/src/node/defaultOptions.ts +++ b/theme/src/node/defaultOptions.ts @@ -1,55 +1,137 @@ +import type { App } from '@vuepress/core' +import { deepClone, deepMerge } from '@pengzhanbo/utils' import type { PlumeThemeLocaleOptions } from '../shared/index.js' +import { pathJoin } from './utils.js' +import { resolveLocaleOptions } from './resolveLocaleOptions.js' -export const defaultLocaleOption: Partial = { - article: '/article', +const defaultLocales: NonNullable = { + 'en-US': { + selectLanguageName: 'English', + selectLanguageText: 'Languages', + editLinkText: 'Edit this page', + lastUpdatedText: 'Last Updated', + contributorsText: 'Contributors', + }, + 'zh-CN': { + selectLanguageName: '简体中文', + selectLanguageText: '选择语言', + + blog: { pagination: { prevPageText: '上一页', nextPageText: '下一页' } }, + + outlineLabel: '内容大纲', + returnToTopLabel: '返回顶部', + editLinkText: '编辑此页', + lastUpdatedText: '上次更新', + prevPageLabel: '上一页', + nextPageLabel: '下一页', + + notFound: { + code: '404', + title: '页面未找到', + quote: '但是,如果你不改变方向,并且一直寻找,最终可能会到达你要去的地方。', + linkText: '返回首页', + }, + }, +} + +export const fallbackLocaleOption: Partial = { + article: '/article/', notes: { link: '/note', dir: 'notes', notes: [] }, + appearance: true, + // page meta + editLink: true, + lastUpdated: true, + contributors: true, footer: { message: 'Power by VuePress & vuepress-theme-plume', }, - appearance: true, - // page meta - editLink: true, - editLinkText: 'Edit this page', - lastUpdated: true, - lastUpdatedText: 'Last Updated', - contributors: true, - contributorsText: 'Contributors', } -export function mergeLocaleOptions(options: PlumeThemeLocaleOptions) { - if (!options.locales) - options.locales = {} +interface PresetLocale { + home: string + blog: string +} + +const presetLocales: Record = { + 'zh-CN': { + home: '首页', + blog: '博客', + }, + 'en-US': { + home: 'Home', + blog: 'Blog', + }, +} + +export function mergeLocaleOptions(app: App, options: PlumeThemeLocaleOptions) { + options.locales ??= {} if (options.notes) { options.notes = { - ...defaultLocaleOption.notes, + ...fallbackLocaleOption.notes, ...(options.notes ?? {}), } } if (options.footer) { options.footer = { - ...defaultLocaleOption.footer, + ...fallbackLocaleOption.footer, ...options.footer, } } const { locales, ...otherOptions } = options - - if (!locales['/']) - locales['/'] = {} + locales['/'] ??= {} Object.assign(options, { - ...defaultLocaleOption, + ...fallbackLocaleOption, ...options, }) Object.assign(locales['/'], { - ...{ selectLanguageName: 'English' }, - ...JSON.parse(JSON.stringify(otherOptions)), + ...deepClone(otherOptions), ...locales['/'], }) + const langs: Record = {} + Object.keys(app.siteData.locales || {}).forEach((locale) => { + const lang = app.siteData.locales![locale]?.lang || 'en-US' + langs[locale] = lang + if (defaultLocales[lang]) { + locales[locale] = deepMerge( + {}, + defaultLocales[lang], + locales[locale] || {}, + ) + } + }) + + const base = app.siteData.base || '/' + const defaultLang = app.siteData.lang || 'en-US' + const defaultBlog = resolveLocaleOptions(options, 'blog') + Object.keys(locales).forEach((locale) => { + const option = locales[locale] + const lang = langs[locale] || defaultLang + + // 当用户未配置导航栏时,生成默认导航栏 + if (!option.navbar || !option.navbar.length) { + option.navbar = [{ + link: pathJoin(base, locale), + text: presetLocales[lang]?.home || presetLocales[defaultLang].home, + icon: 'material-symbols:home-outline', + }] + const blog = option.blog + const link = blog?.link + ? blog.link + : pathJoin(base, locale, defaultBlog?.link || '/blog/') + link && option.navbar.push({ + link, + text: presetLocales[lang]?.blog || presetLocales[defaultLang].blog, + icon: 'material-symbols:article-outline', + }) + } + }) + return options } diff --git a/theme/src/node/plugins.ts b/theme/src/node/plugins.ts index 8c3e7c94..6d53c5d0 100644 --- a/theme/src/node/plugins.ts +++ b/theme/src/node/plugins.ts @@ -30,6 +30,7 @@ import autoFrontmatter from './autoFrontmatter.js' import { resolveLocaleOptions } from './resolveLocaleOptions.js' import { pathJoin } from './utils.js' import { resolveNotesList } from './resolveNotesList.js' +import { resolvedDocsearchOption, resolvedSearchOptions } from './searchPluginOptions.js' export function setupPlugins( app: App, @@ -129,16 +130,16 @@ export function setupPlugins( })) } - if (options.search !== false) - plugins.push(searchPlugin(options.search)) - - if (options.docsearch !== false && !options.search) { - if (options.docsearch?.appId && options.docsearch?.apiKey) - plugins.push(docsearchPlugin(options.docsearch)) + if (options.docsearch) { + if (options.docsearch.appId && options.docsearch.apiKey) + plugins.push(docsearchPlugin(resolvedDocsearchOption(app, options.docsearch))) else console.error('docsearch plugin: appId and apiKey are both required') } + else if (options.search !== false) { + plugins.push(searchPlugin(resolvedSearchOptions(app, options.search))) + } if (options.shikiji !== false) { plugins.push(shikijiPlugin({ diff --git a/theme/src/node/searchPluginOptions.ts b/theme/src/node/searchPluginOptions.ts new file mode 100644 index 00000000..93435cc0 --- /dev/null +++ b/theme/src/node/searchPluginOptions.ts @@ -0,0 +1,88 @@ +import type { DocsearchPluginOptions } from '@vuepress/plugin-docsearch' +import type { SearchPluginOptions } from '@vuepress/plugin-search' +import type { App } from '@vuepress/core' +import { deepMerge } from '@pengzhanbo/utils' + +// `en-US` is used by default +const defaultDocsearchLocales: NonNullable = { + 'zh-CN': { + placeholder: '搜索文档', + translations: { + button: { + buttonText: '搜索文档', + buttonAriaLabel: '搜索文档', + }, + modal: { + searchBox: { + resetButtonTitle: '清除查询条件', + resetButtonAriaLabel: '清除查询条件', + cancelButtonText: '取消', + cancelButtonAriaLabel: '取消', + }, + startScreen: { + recentSearchesTitle: '搜索历史', + noRecentSearchesText: '没有搜索历史', + saveRecentSearchButtonTitle: '保存至搜索历史', + removeRecentSearchButtonTitle: '从搜索历史中移除', + favoriteSearchesTitle: '收藏', + removeFavoriteSearchButtonTitle: '从收藏中移除', + }, + errorScreen: { + titleText: '无法获取结果', + helpText: '你可能需要检查你的网络连接', + }, + footer: { + selectText: '选择', + navigateText: '切换', + closeText: '关闭', + searchByText: '搜索提供者', + }, + noResultsScreen: { + noResultsText: '无法找到相关结果', + suggestedQueryText: '你可以尝试查询', + reportMissingResultsText: '你认为该查询应该有结果?', + reportMissingResultsLinkText: '点击反馈', + }, + }, + }, + }, +} + +const defaultSearchLocales: NonNullable = { + 'zh-CN': { placeholder: '搜索' }, + 'en-US': { placeholder: 'Search' }, +} + +export function resolvedDocsearchOption(app: App, options: DocsearchPluginOptions): DocsearchPluginOptions { + options.locales ??= {} + + Object.keys(app.siteData.locales || {}).forEach((locale) => { + const lang = app.siteData.locales![locale]?.lang || 'en-US' + if (defaultDocsearchLocales[lang]) { + options.locales![locale] = deepMerge( + {}, + defaultDocsearchLocales[lang], + options.locales![locale] || {}, + ) + } + }) + + return options +} + +export function resolvedSearchOptions(app: App, options: SearchPluginOptions = {}): SearchPluginOptions { + options.locales ??= {} + + Object.keys(app.siteData.locales || {}).forEach((locale) => { + const lang = app.siteData.locales![locale]?.lang || 'en-US' + if (defaultSearchLocales[lang]) { + options.locales![locale] = deepMerge( + {}, + defaultSearchLocales[lang], + options.locales![locale] || {}, + ) + } + }) + + return options +} diff --git a/theme/src/node/setupPages.ts b/theme/src/node/setupPages.ts index 12f61687..a22f9f11 100644 --- a/theme/src/node/setupPages.ts +++ b/theme/src/node/setupPages.ts @@ -13,29 +13,24 @@ export async function setupPage( app: App, localeOption: PlumeThemeLocaleOptions, ) { - const locales = Object.keys(app.siteData.locales || {}) + const locales = app.siteData.locales || {} const defaultBlog = resolveLocaleOptions(localeOption, 'blog') - for (const [, locale] of locales.entries()) { + for (const [, locale] of Object.keys(locales).entries()) { const blog = resolveLocaleOptions(localeOption, 'blog', locale, false) + const lang = locales[locale].lang || app.siteData.lang const link = blog?.link ? blog.link : pathJoin('/', locale, defaultBlog?.link || '/blog/') const blogPage = await createPage(app, { path: link, - frontmatter: { - lang: locale.replace(/^\/|\/$/g, '') || app.siteData.lang, - type: 'blog', - }, + frontmatter: { lang, type: 'blog' }, }) app.pages.push(blogPage) if (blog?.tags !== false || defaultBlog?.tags !== false) { const tagsPage = await createPage(app, { path: pathJoin(link, 'tags/'), - frontmatter: { - lang: locale.replace(/^\/|\/$/g, '') || app.siteData.lang, - type: 'blog-tags', - }, + frontmatter: { lang, type: 'blog-tags' }, }) app.pages.push(tagsPage) } @@ -43,10 +38,7 @@ export async function setupPage( if (blog?.archives !== false || defaultBlog?.archives !== false) { const archivesPage = await createPage(app, { path: pathJoin(link, 'archives/'), - frontmatter: { - lang: locale.replace(/^\/|\/$/g, '') || app.siteData.lang, - type: 'blog-archives', - }, + frontmatter: { lang, type: 'blog-archives' }, }) app.pages.push(archivesPage) } diff --git a/theme/src/node/theme.ts b/theme/src/node/theme.ts index 7af76c53..9e0b3969 100644 --- a/theme/src/node/theme.ts +++ b/theme/src/node/theme.ts @@ -13,23 +13,25 @@ export function plumeTheme({ plugins, ...localeOptions }: PlumeThemeOptions = {}): Theme { - localeOptions = mergeLocaleOptions(localeOptions) const pluginsOptions = plugins ?? themePlugins ?? {} const pkg = getThemePackage() - return app => ({ - name: THEME_NAME, - templateBuild: templates('build.html'), - clientConfigFile: resolve('client/config.js'), - plugins: setupPlugins(app, pluginsOptions, localeOptions), - onInitialized: app => setupPage(app, localeOptions), - extendsPage: page => extendsPageData(app, page as Page, localeOptions), - templateBuildRenderer(template, context) { - template = template - .replace('{{ themeVersion }}', pkg.version || '') - .replace(/^\s+|\s+$/gm, '') - .replace(/\n/g, '') - return templateRenderer(template, context) - }, - }) + return (app) => { + localeOptions = mergeLocaleOptions(app, localeOptions) + return { + name: THEME_NAME, + templateBuild: templates('build.html'), + clientConfigFile: resolve('client/config.js'), + plugins: setupPlugins(app, pluginsOptions, localeOptions), + onInitialized: app => setupPage(app, localeOptions), + extendsPage: page => extendsPageData(app, page as Page, localeOptions), + templateBuildRenderer(template, context) { + template = template + .replace('{{ themeVersion }}', pkg.version || '') + .replace(/^\s+|\s+$/gm, '') + .replace(/\n/g, '') + return templateRenderer(template, context) + }, + } + } }