diff --git a/docs/theme.config.ts b/docs/theme.config.ts index 50c606474..0c19ca4ad 100644 --- a/docs/theme.config.ts +++ b/docs/theme.config.ts @@ -1,6 +1,5 @@ import { OPEN_SOURCE_ADDRESS } from '@142vip/utils' -import { markdownImagePlugin } from '@vuepress/plugin-markdown-image' -import { hopeTheme, navbar, sidebar } from 'vuepress-theme-hope' +import { defineVipNavbarConfig, defineVipSidebarConfig } from '@142vip/vuepress' import { BattleInterviewSidebar } from './battle-interview/battle-interview.sidebar' import { DevelopSkillSidebar } from './develop-skill/develop-skill.sidebar' import { FrontEndSidebar } from './front-end/front-end.sidebar' @@ -28,7 +27,7 @@ import { soloAlgorithmSidebar } from './solo-algorithm/solo-algorithm.sidebar' /** * 导航栏 */ -export const navbarConfig = navbar([ +export const navbarConfig = defineVipNavbarConfig([ { text: '🌐 首页', link: '/' }, { text: '🧠 SOLO算法', children: soloAlgorithmSidebar }, { text: '💡 Battle面试官', link: '/battle-interview/' }, @@ -64,7 +63,7 @@ export const navbarConfig = navbar([ /** * 侧边栏 */ -export const sidebarConfig = sidebar({ +export const sidebarConfig = defineVipSidebarConfig({ '/front-end': FrontEndSidebar, '/server-end': ServerEndSidebar, '/server-end/framework/egg-tutorial': EggSidebar, @@ -92,235 +91,235 @@ export const sidebarConfig = sidebar({ * 主题相关配置【备份】 * 参考:https://theme-hope.vuejs.press/zh/config/intro.html#%E9%85%8D%E7%BD%AE%E6%A6%82%E5%BF%B5 */ -export const themeConfig = { - theme: hopeTheme({ - // locales: i18n, - // navbarIcon: false, - // 在深色模式和浅色模式之间切换 - darkmode: 'toggle', - // 支持全屏 - // fullscreen: true, - // 纯净模式 - // pure: true, - // 打印按钮 - print: false, - hostname: 'https://142vip.cn', - // author: AUTHOR_INFO, - favicon: '/favicon.ico', - logo: '/favicon.icon', - - // 导航栏 - navbar: navbarConfig, - // 导航栏布局 - navbarLayout: { - start: ['Brand'], - center: [], - end: ['Links', 'Language', 'Search', 'Outlook', 'Repo'], - }, - // 侧边栏 - sidebar: sidebarConfig, - pageInfo: ['Author', 'Original', 'Date', 'Category', 'Tag', 'ReadingTime'], - // 主题布局选项 - // docsRepo: RepoAddress, - docsDir: 'docs', - docsBranch: 'next', - repo: '142vip/JavaScriptCollection', - repoLabel: 'GitHub', - // 是否在导航栏内显示仓库链接,默认为 `true` - repoDisplay: true, - // 设置页脚 - displayFooter: true, - // footer: FOOTER_HTML_INFO, - // copyright: COPYRIGHT, - // 主题色选择器 - themeColor: true, - // 是否显示外部链接图标 - externalLinkIcon: false, - // 博客配置 - // blog: { - // name: '测试', - // avatar: '', - // description: '', - // intro: '', - // roundAvatar: true, - // timeline: "时间轴的顶部文字", - // // articleInfo: "", - // medias: { - // "BiliBili": "https://space.bilibili.com/350937042?spm_id_from=333.1007.0.0" - // } - // }, - plugins: { - // comment:{ - // provider: "Artalk", - // server:"https://test.142vip.cn/", - // site:'JavaScriptCollection', - // }, - // 公告 参考:https://theme-hope.vuejs.press/zh/guide/feature/notice.html - // notice: [ - // { - // path: '/', - // title: '在线浏览', - // content: '网站无法访问时,建议通过科学上网访问备用网络', - // actions: [ - // { - // text: '尝鲜版', - // link: 'https://142vip.github.io/JavaScriptCollection', - // type: 'default', - // }, - // { - // text: '稳定版', - // link: 'https://code.142vip.cn', - // type: 'primary', - // }, - // ], - // fullscreen: false, - // }, - // ], - readingTime: { - wordPerMinute: 100, - }, - // 水印 - // watermark: { - // enabled: true, - // watermarkOptions: { - // content: '微信公众号:储凡', - // }, - // }, - copyright: false, - // 开启博客功能 - blog: false, - // 图片增强,参考:https://ecosystem.vuejs.press/zh/plugins/markdown/markdown-image.html - markdownImage: markdownImagePlugin({ - // 启用 figure - figure: true, - // 启用图片懒加载 - lazyload: true, - // 启用图片标记 - mark: true, - // 启用图片大小 - size: true, - }), - // 代码块 - mdEnhance: { - // card:true, - // codetabs: true, - // tabs: true, - // 支持任务列表 - tasklist: true, - playground: { - presets: ['ts', 'vue'], - }, - // revealjs: ["highlight", "math", "search", "notes", "zoom"], - stylize: [ - { - matcher: 'Recommended', - replacer: ({ tag }) => { - if (tag === 'em') { - return { - tag: 'Badge', - attrs: { type: 'tip' }, - content: 'Recommended', - } - } - }, - }, - ], - sub: true, - sup: true, - vPre: true, - vuePlayground: true, - // 文件导入,配置别名 - include: true, - // mermaid - mermaid: true, - // 自定义对齐 - align: true, - }, - copyCode: { - showInMobile: true, - }, - // 不自动生成README目录 - catalog: false, - // 参考:https://theme-hope.vuejs.press/zh/guide/markdown/components.html - components: { - components: [ - 'Badge', - 'BiliBili', - 'CodePen', - 'PDF', - 'StackBlitz', - 'VidStack', - 'Share', - 'XiGua', - ], - }, - // searchPro: { - // // 参考:https://plugin-search-pro.vuejs.press/zh/config.html#locales - // locales: { - // '/': searchProCNLocals, - // }, - // }, - // 代码高亮:https://theme-hope.vuejs.press/zh/guide/feature/code-block.html - shiki: { - langs: [ - 'ts', - 'js', - 'json', - 'vue', - 'json5', - 'bash', - 'diff', - 'c', - 'c++', - 'dockerfile', - 'nginx', - 'proto', - 'java', - 'javascript', - 'typescript', - 'yaml', - ], - // 你想要使用的主题 - themes: { - light: 'one-light', - dark: 'one-dark-pro', - }, - }, - // shiki: shikiPlugin({ - // // 配置项 - // langs: [ - // 'java', - // 'javascript', - // 'typescript', - // 'html', - // 'css', - // 'json', - // 'yaml', - // 'markdown', - // 'xml', - // 'bat', - // 'shell', - // 'powershell', - // 'sql', - // 'properties', - // 'md', - // 'vue', - // 'tsx', - // 'jsx', - // 'scss', - // 'less', - // 'sass', - // 'vue-html', - // 'nginx', - // 'tex', - // ], - // themes: { - // // light: 'one-light', - // // dark: 'one-dark-pro', - // dark: 'dark-plus', - // light: 'light-plus', - // }, - // }), - }, - }), -} +// export const themeConfig = { +// theme: hopeTheme({ +// // locales: i18n, +// // navbarIcon: false, +// // 在深色模式和浅色模式之间切换 +// darkmode: 'toggle', +// // 支持全屏 +// // fullscreen: true, +// // 纯净模式 +// // pure: true, +// // 打印按钮 +// print: false, +// hostname: 'https://142vip.cn', +// // author: AUTHOR_INFO, +// favicon: '/favicon.ico', +// logo: '/favicon.icon', +// +// // 导航栏 +// navbar: navbarConfig, +// // 导航栏布局 +// navbarLayout: { +// start: ['Brand'], +// center: [], +// end: ['Links', 'Language', 'Search', 'Outlook', 'Repo'], +// }, +// // 侧边栏 +// sidebar: sidebarConfig, +// pageInfo: ['Author', 'Original', 'Date', 'Category', 'Tag', 'ReadingTime'], +// // 主题布局选项 +// // docsRepo: RepoAddress, +// docsDir: 'docs', +// docsBranch: 'next', +// repo: '142vip/JavaScriptCollection', +// repoLabel: 'GitHub', +// // 是否在导航栏内显示仓库链接,默认为 `true` +// repoDisplay: true, +// // 设置页脚 +// displayFooter: true, +// // footer: FOOTER_HTML_INFO, +// // copyright: COPYRIGHT, +// // 主题色选择器 +// themeColor: true, +// // 是否显示外部链接图标 +// externalLinkIcon: false, +// // 博客配置 +// // blog: { +// // name: '测试', +// // avatar: '', +// // description: '', +// // intro: '', +// // roundAvatar: true, +// // timeline: "时间轴的顶部文字", +// // // articleInfo: "", +// // medias: { +// // "BiliBili": "https://space.bilibili.com/350937042?spm_id_from=333.1007.0.0" +// // } +// // }, +// plugins: { +// // comment:{ +// // provider: "Artalk", +// // server:"https://test.142vip.cn/", +// // site:'JavaScriptCollection', +// // }, +// // 公告 参考:https://theme-hope.vuejs.press/zh/guide/feature/notice.html +// // notice: [ +// // { +// // path: '/', +// // title: '在线浏览', +// // content: '网站无法访问时,建议通过科学上网访问备用网络', +// // actions: [ +// // { +// // text: '尝鲜版', +// // link: 'https://142vip.github.io/JavaScriptCollection', +// // type: 'default', +// // }, +// // { +// // text: '稳定版', +// // link: 'https://code.142vip.cn', +// // type: 'primary', +// // }, +// // ], +// // fullscreen: false, +// // }, +// // ], +// readingTime: { +// wordPerMinute: 100, +// }, +// // 水印 +// // watermark: { +// // enabled: true, +// // watermarkOptions: { +// // content: '微信公众号:储凡', +// // }, +// // }, +// copyright: false, +// // 开启博客功能 +// blog: false, +// // 图片增强,参考:https://ecosystem.vuejs.press/zh/plugins/markdown/markdown-image.html +// markdownImage: markdownImagePlugin({ +// // 启用 figure +// figure: true, +// // 启用图片懒加载 +// lazyload: true, +// // 启用图片标记 +// mark: true, +// // 启用图片大小 +// size: true, +// }), +// // 代码块 +// mdEnhance: { +// // card:true, +// // codetabs: true, +// // tabs: true, +// // 支持任务列表 +// tasklist: true, +// playground: { +// presets: ['ts', 'vue'], +// }, +// // revealjs: ["highlight", "math", "search", "notes", "zoom"], +// stylize: [ +// { +// matcher: 'Recommended', +// replacer: ({ tag }) => { +// if (tag === 'em') { +// return { +// tag: 'Badge', +// attrs: { type: 'tip' }, +// content: 'Recommended', +// } +// } +// }, +// }, +// ], +// sub: true, +// sup: true, +// vPre: true, +// vuePlayground: true, +// // 文件导入,配置别名 +// include: true, +// // mermaid +// mermaid: true, +// // 自定义对齐 +// align: true, +// }, +// copyCode: { +// showInMobile: true, +// }, +// // 不自动生成README目录 +// catalog: false, +// // 参考:https://theme-hope.vuejs.press/zh/guide/markdown/components.html +// components: { +// components: [ +// 'Badge', +// 'BiliBili', +// 'CodePen', +// 'PDF', +// 'StackBlitz', +// 'VidStack', +// 'Share', +// 'XiGua', +// ], +// }, +// // searchPro: { +// // // 参考:https://plugin-search-pro.vuejs.press/zh/config.html#locales +// // locales: { +// // '/': searchProCNLocals, +// // }, +// // }, +// // 代码高亮:https://theme-hope.vuejs.press/zh/guide/feature/code-block.html +// shiki: { +// langs: [ +// 'ts', +// 'js', +// 'json', +// 'vue', +// 'json5', +// 'bash', +// 'diff', +// 'c', +// 'c++', +// 'dockerfile', +// 'nginx', +// 'proto', +// 'java', +// 'javascript', +// 'typescript', +// 'yaml', +// ], +// // 你想要使用的主题 +// themes: { +// light: 'one-light', +// dark: 'one-dark-pro', +// }, +// }, +// // shiki: shikiPlugin({ +// // // 配置项 +// // langs: [ +// // 'java', +// // 'javascript', +// // 'typescript', +// // 'html', +// // 'css', +// // 'json', +// // 'yaml', +// // 'markdown', +// // 'xml', +// // 'bat', +// // 'shell', +// // 'powershell', +// // 'sql', +// // 'properties', +// // 'md', +// // 'vue', +// // 'tsx', +// // 'jsx', +// // 'scss', +// // 'less', +// // 'sass', +// // 'vue-html', +// // 'nginx', +// // 'tex', +// // ], +// // themes: { +// // // light: 'one-light', +// // // dark: 'one-dark-pro', +// // dark: 'dark-plus', +// // light: 'light-plus', +// // }, +// // }), +// }, +// }), +// } diff --git a/package.json b/package.json index f5352e4c1..620d6f31d 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,10 @@ "@142vip/eslint-config": "0.0.1-alpha.4", "@142vip/fairy-cli": "0.0.3-alpha.24", "@142vip/utils": "0.0.1-alpha.36", - "@142vip/vuepress": "0.0.1-alpha.12", - "@vuepress/bundler-vite": "2.0.0-rc.20", + "@142vip/vuepress": "0.0.1-alpha.14", "only-allow": "1.2.1", "simple-git-hooks": "2.11.1", - "ts-node": "^10.9.2", - "vuepress": "2.0.0-rc.20" + "ts-node": "10.9.2" }, "simple-git-hooks": { "pre-commit": "pnpm lint:fix", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cf570384c..690e889fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,11 +21,8 @@ importers: specifier: 0.0.1-alpha.36 version: 0.0.1-alpha.36(@types/node@22.15.14) '@142vip/vuepress': - specifier: 0.0.1-alpha.12 - version: 0.0.1-alpha.12(dg7enuvwinb4xviyjji7ux3mpi) - '@vuepress/bundler-vite': - specifier: 2.0.0-rc.20 - version: 2.0.0-rc.20(@types/node@22.15.14)(jiti@2.4.2)(sass-embedded@1.80.4)(typescript@5.6.3)(yaml@2.7.1) + specifier: 0.0.1-alpha.14 + version: 0.0.1-alpha.14(curdsjmnxwvpt7bre5g4lzdfd4) only-allow: specifier: 1.2.1 version: 1.2.1 @@ -33,11 +30,8 @@ importers: specifier: 2.11.1 version: 2.11.1 ts-node: - specifier: ^10.9.2 + specifier: 10.9.2 version: 10.9.2(@types/node@22.15.14)(typescript@5.6.3) - vuepress: - specifier: 2.0.0-rc.20 - version: 2.0.0-rc.20(@vuepress/bundler-vite@2.0.0-rc.20(@types/node@22.15.14)(jiti@2.4.2)(sass-embedded@1.80.4)(typescript@5.6.3)(yaml@2.7.1))(typescript@5.6.3)(vue@3.5.13(typescript@5.6.3)) code/express/apps/apis-demo: dependencies: @@ -145,26 +139,29 @@ packages: '@142vip/utils@0.0.1-alpha.36': resolution: {integrity: sha512-nHPaDzDVkeCojnMEgaejXjx4f9s6/srdJhZV189V+TYNV9E4ys+GQYqS2lhZBje4qvlNTeWpW4tahrDOsBWpZA==} - '@142vip/vuepress@0.0.1-alpha.12': - resolution: {integrity: sha512-dTn5q6vbhZrgues7QdTM6pNoDZWSPdhwvtKd0VCa7Jgw4F838nnEjjpmpYh7M+T1wmmttETDUe1Xaa3IpbNyKw==} + '@142vip/vuepress@0.0.1-alpha.14': + resolution: {integrity: sha512-FWvJAZVKXe6XUhJLWivNfUtLqxu6y1w86OxBajh/uBd+pnMQD1YeUcUQK9heIs4wgcEyJoQlf0MmFoCQ9toh+Q==} peerDependencies: '@vue/repl': 4.5.1 - '@vuepress/bundler-vite': 2.0.0-rc.20 - '@vuepress/plugin-markdown-image': 2.0.0-rc.92 - '@vuepress/plugin-markdown-tab': 2.0.0-rc.92 - '@vuepress/plugin-redirect': 2.0.0-rc.92 - '@vuepress/plugin-slimsearch': 2.0.0-rc.92 + '@vuepress/bundler-vite': 2.0.0-rc.23 + '@vuepress/plugin-markdown-image': 2.0.0-rc.99 + '@vuepress/plugin-markdown-tab': 2.0.0-rc.99 + '@vuepress/plugin-redirect': 2.0.0-rc.99 + '@vuepress/plugin-slimsearch': 2.0.0-rc.99 '@vueuse/shared': 13.0.0 + cli-spinners: 3.2.0 dashjs: 4.7.4 hls.js: 1.5.13 + markdown-it: 14.1.0 + markdown-it-emoji: 3.0.0 mermaid: 11.6.0 reveal.js: 5.2.1 - sass-embedded: 1.86.0 + sass-embedded: 1.87.0 unicorn-magic: 0.3.0 vidstack: 1.12.12 vue: 3.5.13 - vuepress: 2.0.0-rc.20 - vuepress-theme-hope: 2.0.0-rc.77 + vuepress: 2.0.0-rc.23 + vuepress-theme-hope: 2.0.0-rc.87 '@antfu/eslint-config@4.11.0': resolution: {integrity: sha512-KMLIrZflEFsOEF/N0Xl8iVaheLTdgT3gAwXVzdG5Ng8ieNhBsRsaThnqI7of10kh6psSBLJ6SkNK+ZF98fQIXQ==} @@ -4874,7 +4871,7 @@ snapshots: - '@types/node' - magicast - '@142vip/vuepress@0.0.1-alpha.12(dg7enuvwinb4xviyjji7ux3mpi)': + '@142vip/vuepress@0.0.1-alpha.14(curdsjmnxwvpt7bre5g4lzdfd4)': dependencies: '@vue/repl': 4.4.2 '@vuepress/bundler-vite': 2.0.0-rc.20(@types/node@22.15.14)(jiti@2.4.2)(sass-embedded@1.80.4)(typescript@5.6.3)(yaml@2.7.1) @@ -4883,8 +4880,11 @@ snapshots: '@vuepress/plugin-redirect': 2.0.0-rc.56(typescript@5.6.3)(vuepress@2.0.0-rc.20(@vuepress/bundler-vite@2.0.0-rc.20(@types/node@22.15.14)(jiti@2.4.2)(sass-embedded@1.80.4)(typescript@5.6.3)(yaml@2.7.1))(typescript@5.6.3)(vue@3.5.13(typescript@5.6.3))) '@vuepress/plugin-slimsearch': 2.0.0-rc.61(typescript@5.6.3)(vuepress@2.0.0-rc.20(@vuepress/bundler-vite@2.0.0-rc.20(@types/node@22.15.14)(jiti@2.4.2)(sass-embedded@1.80.4)(typescript@5.6.3)(yaml@2.7.1))(typescript@5.6.3)(vue@3.5.13(typescript@5.6.3))) '@vueuse/shared': 11.3.0(vue@3.5.13(typescript@5.6.3)) + cli-spinners: 2.9.2 dashjs: 4.7.4 hls.js: 1.5.17 + markdown-it: 14.1.0 + markdown-it-emoji: 3.0.0 mermaid: 10.9.3 reveal.js: 5.1.0 sass-embedded: 1.80.4 @@ -8556,7 +8556,7 @@ snapshots: micromark@3.2.0: dependencies: '@types/debug': 4.1.12 - debug: 4.4.0 + debug: 4.0.0 decode-named-character-reference: 1.1.0 micromark-core-commonmark: 1.1.0 micromark-factory-space: 1.1.0 diff --git a/tsconfig.json b/tsconfig.json index 8ad626671..e29dbc574 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,7 +20,7 @@ "strictNullChecks": true, "noImplicitThis": true, "noUnusedLocals": true, - "declaration": true, + "declaration": false, "inlineSourceMap": true, "stripInternal": true, "allowSyntheticDefaultImports": true, diff --git a/vuepress.config.ts b/vuepress.config.ts index 3f20a62ac..822c3ae38 100644 --- a/vuepress.config.ts +++ b/vuepress.config.ts @@ -1,19 +1,17 @@ -import { getDocSiteBase, GitGeneralBranch, OPEN_SOURCE_ADDRESS, OPEN_SOURCE_AUTHOR } from '@142vip/utils' +import { getDocSiteBase, GitGeneralBranch, OPEN_SOURCE_ADDRESS, OPEN_SOURCE_AUTHOR, VipPackageJSON } from '@142vip/utils' import { + defineVipVuepressConfig, getCopyRightText, getFooterHtml, - getThemeConfig, - getViteBundler, + getVipHopeTheme, + handleImportCodePath, JSCHeaders, } from '@142vip/vuepress' -import { viteBundler } from '@vuepress/bundler-vite' -import { defineUserConfig } from '@vuepress/cli' -import { getDirname, path } from '@vuepress/utils' -import { hopeTheme } from 'vuepress-theme-hope' import { navbarConfig, sidebarConfig } from './docs/theme.config' -import pkg from './package.json' -export default defineUserConfig({ +const pkg = VipPackageJSON.getPackageJSON<{ description: string }>() + +export default defineVipVuepressConfig({ base: getDocSiteBase(pkg.name), title: '凡是过往、皆为序章', description: pkg.description, @@ -21,23 +19,12 @@ export default defineUserConfig({ head: JSCHeaders, source: '', markdown: { - // todo 引入代码文件时的路径替换 https://vuejs.press/zh/guide/markdown.html#%E5%AF%BC%E5%85%A5%E4%BB%A3%E7%A0%81%E5%9D%97 importCode: { - handleImportPath: (str) => { - // 当前目录名 - const __dirname = getDirname(import.meta.url) - - if (str.includes('@code')) { - return str.replace(/^@code/, path.resolve(__dirname, 'code/')) - } - if (str.includes('@algorithm')) { - return str.replace(/^@algorithm/, path.resolve(__dirname, 'code/algorithm/')) - } - if (str.includes('~')) { - return str.replace(/^~/, path.resolve(__dirname, '')) - } - return str - }, + handleImportPath: handleImportCodePath([ + ['@code', 'code'], + ['@algorithm', 'code/algorithm'], + ['~', ''], + ]), }, // md doc formatter headerDepth headers: { @@ -45,45 +32,41 @@ export default defineUserConfig({ }, }, // 主题配置 - theme: hopeTheme({ - ...getThemeConfig({ - // 导航栏 - navbar: navbarConfig, - // 侧边栏 - sidebar: sidebarConfig, - // 页脚 - footer: getFooterHtml({ - name: pkg.name, - version: pkg.version, - }), - // 版权 - copyright: getCopyRightText(OPEN_SOURCE_AUTHOR.name), - // 仓库 - repo: '142vip/JavaScriptCollection', - repoLabel: 'GitHub', + theme: getVipHopeTheme({ + // 导航栏 + navbar: navbarConfig, + // 侧边栏 + sidebar: sidebarConfig, + // 页脚 + footer: getFooterHtml({ + name: pkg.name, + version: pkg.version, + }), + // 版权 + copyright: getCopyRightText(OPEN_SOURCE_AUTHOR.name), + // 仓库 + repo: '142vip/JavaScriptCollection', + repoLabel: 'GitHub', - // 作者信息 - author: OPEN_SOURCE_AUTHOR, + // 作者信息 + author: OPEN_SOURCE_AUTHOR, - // 文档路径,开启编辑功能 - docsDir: 'docs', - docsBranch: GitGeneralBranch.NEXT, - // 主题布局选项 - docsRepo: OPEN_SOURCE_ADDRESS.GITHUB_REPO_JSC, + // 文档路径,开启编辑功能 + docsDir: 'docs', + docsBranch: GitGeneralBranch.NEXT, + // 主题布局选项 + docsRepo: OPEN_SOURCE_ADDRESS.GITHUB_REPO_JSC, - // 插件 - plugins: { - // 水印 - watermark: { - enabled: false, - watermarkOptions: { - content: OPEN_SOURCE_AUTHOR.name, - }, + // 插件 + plugins: { + // 水印 + watermark: { + enabled: false, + watermarkOptions: { + content: OPEN_SOURCE_AUTHOR.name, }, }, - }), + }, }), - // 编译 - bundler: viteBundler(getViteBundler()), shouldPrefetch: false, })