From 95549c79fb149310ec11795e795ae9d0537bffce Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 19 Jul 2022 21:58:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=EF=BC=9A=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +- repos/.vitepress/config.js | 103 ------------- repos/.vitepress/config.ts | 142 ++++++++++++++++++ ...提交记录.md => 25.合并两个Git仓库的历史提交记录.md} | 0 ...站.md => 01.F盘上的回收站已损坏。是否清空该驱动器上的回收站.md} | 0 ...的陷阱.md => 08.for循环中删除集合元素隐藏的陷阱.md} | 0 ... for Spring Boot default configuration.md} | 0 ...法读取.md => 13.无法访问F盘。文件或目录损坏且无法读取.md} | 0 ...> 26.JavaScript 无法存储 Java Long 类型数据问题.md} | 0 9 files changed, 144 insertions(+), 104 deletions(-) delete mode 100644 repos/.vitepress/config.js create mode 100644 repos/.vitepress/config.ts rename repos/fragments/2022/03/{合并两个Git仓库的历史提交记录.md => 25.合并两个Git仓库的历史提交记录.md} (100%) rename repos/issues/2021/12/{F盘上的回收站已损坏。是否清空该驱动器上的回收站.md => 01.F盘上的回收站已损坏。是否清空该驱动器上的回收站.md} (100%) rename repos/issues/2021/12/{for循环中删除集合元素隐藏的陷阱.md => 08.for循环中删除集合元素隐藏的陷阱.md} (100%) rename repos/issues/2021/12/{Command line is too long. Shorten command line for XXX or also for Spring Boot default configuration.md => 10.Command line is too long. Shorten command line for XXX or also for Spring Boot default configuration.md} (100%) rename repos/issues/2021/12/{无法访问F盘。文件或目录损坏且无法读取.md => 13.无法访问F盘。文件或目录损坏且无法读取.md} (100%) rename repos/issues/2022/01/{JavaScript 无法存储 Java Long 类型数据问题.md => 26.JavaScript 无法存储 Java Long 类型数据问题.md} (100%) diff --git a/package.json b/package.json index 76241ed51..5b5b85bd1 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ }, "devDependencies": { "vitepress": "^1.0.0-alpha.4", - "vue": "^3.2.37" + "vue": "^3.2.37", + "fast-glob": "^3.2.11" } } diff --git a/repos/.vitepress/config.js b/repos/.vitepress/config.js deleted file mode 100644 index b4b49911c..000000000 --- a/repos/.vitepress/config.js +++ /dev/null @@ -1,103 +0,0 @@ -export default { - lang: 'zh-CN', - title: '查尔斯的知识库', - description: '个人知识库,记录 & 分享个人碎片化、结构化、体系化的知识内容。', - - // 设置 - head: [ - ['link', { rel: 'icon', href: '/favicon.ico' }] - ], - - lastUpdated: true, // 启用最后更新时间 - - themeConfig: { - logo: '/logo.jpg', - outlineTitle: '本页内容', // 右侧边栏的大纲标题 - // 编辑链接 - editLink: { - pattern: 'https://github.com/Charles7c/charles7c.github.io/edit/main/repos/:path', - text: '在 GitHub 上编辑此页面' - }, - lastUpdatedText: '最后更新', // 最后更新时间文本 - docFooter: { - prev: '上一页', - next: '下一页' - }, - // 版权标识 - footer: { - message: 'Released under the MIT License.', - copyright: 'Copyright © 2019-present Charles7c' - }, - // 社交链接 - socialLinks: [ - { icon: 'github', link: 'https://github.com/Charles7c/charles7c.github.io' } - ], - // 全文搜索 - algolia: { - appId: 'DBZ0G9HBUY', - apiKey: '00cef480a543003d05d9808110ea5f65', - indexName: 'charles7c' - }, - - // 导航栏 - nav: nav(), - - // 侧边栏 - sidebar: { - '/issues/': sidebarIssues(), - '/fragments/': sidebarFragments(), - '/about/': sidebarAbout() - } - } -} - -function nav() { - return [ - { - text: 'Bug万象集', - link: '/issues/index' - }, - { - text: '"杂碎"逆袭史', - link: '/fragments/index' - }, - { - text: '关于知识库', - link: '/about/index' - } - ] -} - -function sidebarIssues() { - return [ - { - items: [ - { text: 'JavaScript 无法存储 Java Long 类型数据问题', link: '/issues/2022/01/JavaScript 无法存储 Java Long 类型数据问题' }, - { text: '无法访问 F:\\。文件或目录损坏且无法读取。', link: '/issues/2021/12/无法访问F盘。文件或目录损坏且无法读取' }, - { text: 'Command line is too long. Shorten command line for XXX or also for Spring Boot default configuration?', link: '/issues/2021/12/Command line is too long. Shorten command line for XXX or also for Spring Boot default configuration' }, - { text: 'for循环中删除集合元素隐藏的陷阱', link: '/issues/2021/12/for循环中删除集合元素隐藏的陷阱' }, - { text: 'F:\\ 上的回收站已损坏。是否清空该驱动器上的"回收站"?', link: '/issues/2021/12/F盘上的回收站已损坏。是否清空该驱动器上的回收站' } - ] - } - ] -} - -function sidebarFragments() { - return [ - { - items: [ - { text: '合并两个Git仓库的历史提交记录', link: '/fragments/2022/03/合并两个Git仓库的历史提交记录' } - ] - } - ] -} - -function sidebarAbout() { - return [ - { - items: [ - { text: '关于笔者', link: '/about/me' } - ] - } - ] -} diff --git a/repos/.vitepress/config.ts b/repos/.vitepress/config.ts new file mode 100644 index 000000000..aca091795 --- /dev/null +++ b/repos/.vitepress/config.ts @@ -0,0 +1,142 @@ +import { defineConfig, type DefaultTheme } from 'vitepress' +import { sync } from "fast-glob" + +export default defineConfig({ + lang: 'zh-CN', + title: '查尔斯的知识库', + description: '个人知识库,记录 & 分享个人碎片化、结构化、体系化的知识内容。', + lastUpdated: true, // 显示最后更新时间 + + // 内标签配置 + head: [ + ['link', { rel: 'icon', href: '/favicon.ico' }] + ], + // Markdown配置 + markdown: { + theme: 'material-palenight', + // lineNumbers: true + }, + + // 主题配置 + themeConfig: { + logo: '/logo.jpg', + outlineTitle: '目录', // 右侧边栏的大纲标题文本 + // 编辑链接 + editLink: { + pattern: 'https://github.com/Charles7c/charles7c.github.io/edit/main/repos/:path', + text: '在 GitHub 上编辑此页面' + }, + lastUpdatedText: '最后更新', // 最后更新时间文本, 需配置 lastUpdated 为 true + docFooter: { + prev: '上一页', + next: '下一页' + }, + // 版权标识 + footer: { + message: 'Released under the MIT License.', + copyright: 'Copyright © 2019-present Charles7c' + }, + // 社交链接 + socialLinks: [ + { icon: 'github', link: 'https://github.com/Charles7c/charles7c.github.io' } + ], + // 全文搜索 + algolia: { + appId: 'DBZ0G9HBUY', + apiKey: '00cef480a543003d05d9808110ea5f65', + indexName: 'charles7c' + }, + + // 导航栏 + nav: nav(), + + // 侧边栏 + sidebar: { + '/issues/': getItems("issues"), + '/fragments/': getItems("fragments"), + '/about/': [ + { + items: [ + { text: '关于笔者', link: '/about/me' } + ] + } + ] + } + } +}) + +/** + * 获取导航栏 + */ +function nav() { + return [ + { + text: 'Bug万象集', + link: '/issues/index' + }, + { + text: '"杂碎"逆袭史', + link: '/fragments/index' + }, + { + text: '关于知识库', + link: '/about/index' + } + ] +} + +/** + * 获取侧边栏分组及分组下标题 + * + * @param path 扫描基础路径 + * @returns {DefaultTheme.SidebarGroup[]} + */ +function getItems (path: string) { + // 侧边栏分组数组 + let groups: DefaultTheme.SidebarGroup[] = [] + // 侧边栏分组下标题数组 + let items: DefaultTheme.SidebarItem[] = [] + + // 1.获取所有年份目录 + sync(`repos/${path}/*`, { + onlyDirectories: true, + objectMode: true, + }).forEach(({ name }) => { + let year = name + for (let i = 1; i <= 12; i++) { + let month = i < 10 ? `0${i}` : i + // 2.获取所有月份目录下的文章 + sync(`repos/${path}/${year}/${month}/*`, { + objectMode: true, + }).forEach(({ name }) => { + // 向前追加标题 + items.unshift({ + text: name, + link: `/${path}/${year}/${month}/${name}`, + }) + }) + + // 3.向前追加分组 + if (items.length > 0) { + // 去除标题名中的日期前缀和扩展名 + for (let i = 0; i < items.length; i++) { + let text = items[i].text + items[i].text = text.replace('.md', '').substring(text.indexOf('.') + 1) + } + groups.unshift({ + text: `${year}年${month}月 (${items.length}篇)`, + collapsible: true, + collapsed: true, + items: items + }) + } + + // 4.清空侧边栏分组下标题数组 + items = [] + } + }) + + // 5.将第一个侧边栏分组的标题展开 + groups[0].collapsed = false + return groups +} \ No newline at end of file diff --git a/repos/fragments/2022/03/合并两个Git仓库的历史提交记录.md b/repos/fragments/2022/03/25.合并两个Git仓库的历史提交记录.md similarity index 100% rename from repos/fragments/2022/03/合并两个Git仓库的历史提交记录.md rename to repos/fragments/2022/03/25.合并两个Git仓库的历史提交记录.md diff --git a/repos/issues/2021/12/F盘上的回收站已损坏。是否清空该驱动器上的回收站.md b/repos/issues/2021/12/01.F盘上的回收站已损坏。是否清空该驱动器上的回收站.md similarity index 100% rename from repos/issues/2021/12/F盘上的回收站已损坏。是否清空该驱动器上的回收站.md rename to repos/issues/2021/12/01.F盘上的回收站已损坏。是否清空该驱动器上的回收站.md diff --git a/repos/issues/2021/12/for循环中删除集合元素隐藏的陷阱.md b/repos/issues/2021/12/08.for循环中删除集合元素隐藏的陷阱.md similarity index 100% rename from repos/issues/2021/12/for循环中删除集合元素隐藏的陷阱.md rename to repos/issues/2021/12/08.for循环中删除集合元素隐藏的陷阱.md diff --git a/repos/issues/2021/12/Command line is too long. Shorten command line for XXX or also for Spring Boot default configuration.md b/repos/issues/2021/12/10.Command line is too long. Shorten command line for XXX or also for Spring Boot default configuration.md similarity index 100% rename from repos/issues/2021/12/Command line is too long. Shorten command line for XXX or also for Spring Boot default configuration.md rename to repos/issues/2021/12/10.Command line is too long. Shorten command line for XXX or also for Spring Boot default configuration.md diff --git a/repos/issues/2021/12/无法访问F盘。文件或目录损坏且无法读取.md b/repos/issues/2021/12/13.无法访问F盘。文件或目录损坏且无法读取.md similarity index 100% rename from repos/issues/2021/12/无法访问F盘。文件或目录损坏且无法读取.md rename to repos/issues/2021/12/13.无法访问F盘。文件或目录损坏且无法读取.md diff --git a/repos/issues/2022/01/JavaScript 无法存储 Java Long 类型数据问题.md b/repos/issues/2022/01/26.JavaScript 无法存储 Java Long 类型数据问题.md similarity index 100% rename from repos/issues/2022/01/JavaScript 无法存储 Java Long 类型数据问题.md rename to repos/issues/2022/01/26.JavaScript 无法存储 Java Long 类型数据问题.md