From 2b40ec86e4e0cf46289140659e21cea1d5cf65f2 Mon Sep 17 00:00:00 2001 From: eryajf Date: Tue, 16 Apr 2024 22:13:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E9=83=A8=E7=BD=B2=E7=9A=84=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=AB=AF=E5=8F=A3=E6=94=B9=E4=B8=BA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vuepress/config.js | 4 +- ...13\350\257\225\347\216\257\345\242\203.md" | 10 +- vdoing/LICENSE | 21 - vdoing/README.md | 7 - vdoing/components/AlgoliaSearchBox.vue | 166 ------ vdoing/components/ArchivesPage.vue | 207 ------- vdoing/components/ArticleInfo.vue | 203 ------- vdoing/components/BloggerBar.vue | 76 --- vdoing/components/BodyBgImg.vue | 59 -- vdoing/components/Buttons.vue | 264 --------- vdoing/components/Catalogue.vue | 232 -------- vdoing/components/CategoriesBar.vue | 114 ---- vdoing/components/CategoriesPage.vue | 140 ----- vdoing/components/DropdownLink.vue | 228 -------- vdoing/components/DropdownTransition.vue | 32 -- vdoing/components/Footer.vue | 72 --- vdoing/components/Home.vue | 542 ------------------ vdoing/components/MainLayout.vue | 64 --- vdoing/components/NavLink.vue | 54 -- vdoing/components/NavLinks.vue | 154 ----- vdoing/components/Navbar.vue | 141 ----- vdoing/components/Page.vue | 218 ------- vdoing/components/PageEdit.vue | 168 ------ vdoing/components/PageNav.vue | 237 -------- vdoing/components/Pagination.vue | 240 -------- vdoing/components/PostList.vue | 260 --------- vdoing/components/RightMenu.vue | 149 ----- vdoing/components/Sidebar.vue | 113 ---- vdoing/components/SidebarButton.vue | 64 --- vdoing/components/SidebarGroup.vue | 128 ----- vdoing/components/SidebarLink.vue | 130 ----- vdoing/components/SidebarLinks.vue | 93 --- vdoing/components/TagsBar.vue | 110 ---- vdoing/components/TagsPage.vue | 125 ---- vdoing/components/UpdateArticle.vue | 162 ------ vdoing/enhanceApp.js | 47 -- vdoing/global-components/Badge.vue | 44 -- vdoing/global-components/CodeBlock.vue | 38 -- vdoing/global-components/CodeGroup.vue | 99 ---- vdoing/index.js | 292 ---------- vdoing/layouts/404.vue | 35 -- vdoing/layouts/Layout.vue | 379 ------------ vdoing/mixins/posts.js | 21 - vdoing/mixins/titleBadge.js | 28 - vdoing/node_utils/getSidebarData.js | 185 ------ vdoing/node_utils/handlePage.js | 82 --- vdoing/node_utils/modules/fn.js | 21 - vdoing/node_utils/modules/readFileList.js | 45 -- vdoing/node_utils/setFrontmatter.js | 163 ------ vdoing/noopModule.js | 1 - vdoing/package.json | 52 -- vdoing/styles/arrow.styl | 22 - vdoing/styles/code-theme.styl | 274 --------- vdoing/styles/code.styl | 142 ----- vdoing/styles/config.styl | 1 - vdoing/styles/custom-blocks.styl | 87 --- vdoing/styles/index.styl | 318 ---------- vdoing/styles/markdown-container.styl | 211 ------- vdoing/styles/mobile.styl | 101 ---- vdoing/styles/palette.styl | 96 ---- vdoing/styles/toc.styl | 3 - vdoing/styles/wrapper.styl | 17 - vdoing/templates/dev.html | 11 - vdoing/templates/ssr.html | 18 - vdoing/types/index.ts | 175 ------ vdoing/util/index.js | 292 ---------- vdoing/util/postData.js | 108 ---- 67 files changed, 7 insertions(+), 8388 deletions(-) delete mode 100644 vdoing/LICENSE delete mode 100644 vdoing/README.md delete mode 100644 vdoing/components/AlgoliaSearchBox.vue delete mode 100644 vdoing/components/ArchivesPage.vue delete mode 100644 vdoing/components/ArticleInfo.vue delete mode 100644 vdoing/components/BloggerBar.vue delete mode 100644 vdoing/components/BodyBgImg.vue delete mode 100644 vdoing/components/Buttons.vue delete mode 100644 vdoing/components/Catalogue.vue delete mode 100644 vdoing/components/CategoriesBar.vue delete mode 100644 vdoing/components/CategoriesPage.vue delete mode 100644 vdoing/components/DropdownLink.vue delete mode 100644 vdoing/components/DropdownTransition.vue delete mode 100644 vdoing/components/Footer.vue delete mode 100644 vdoing/components/Home.vue delete mode 100644 vdoing/components/MainLayout.vue delete mode 100644 vdoing/components/NavLink.vue delete mode 100644 vdoing/components/NavLinks.vue delete mode 100644 vdoing/components/Navbar.vue delete mode 100644 vdoing/components/Page.vue delete mode 100644 vdoing/components/PageEdit.vue delete mode 100644 vdoing/components/PageNav.vue delete mode 100644 vdoing/components/Pagination.vue delete mode 100644 vdoing/components/PostList.vue delete mode 100644 vdoing/components/RightMenu.vue delete mode 100644 vdoing/components/Sidebar.vue delete mode 100644 vdoing/components/SidebarButton.vue delete mode 100644 vdoing/components/SidebarGroup.vue delete mode 100644 vdoing/components/SidebarLink.vue delete mode 100644 vdoing/components/SidebarLinks.vue delete mode 100644 vdoing/components/TagsBar.vue delete mode 100644 vdoing/components/TagsPage.vue delete mode 100644 vdoing/components/UpdateArticle.vue delete mode 100644 vdoing/enhanceApp.js delete mode 100644 vdoing/global-components/Badge.vue delete mode 100644 vdoing/global-components/CodeBlock.vue delete mode 100644 vdoing/global-components/CodeGroup.vue delete mode 100644 vdoing/index.js delete mode 100644 vdoing/layouts/404.vue delete mode 100644 vdoing/layouts/Layout.vue delete mode 100644 vdoing/mixins/posts.js delete mode 100644 vdoing/mixins/titleBadge.js delete mode 100644 vdoing/node_utils/getSidebarData.js delete mode 100644 vdoing/node_utils/handlePage.js delete mode 100644 vdoing/node_utils/modules/fn.js delete mode 100644 vdoing/node_utils/modules/readFileList.js delete mode 100644 vdoing/node_utils/setFrontmatter.js delete mode 100644 vdoing/noopModule.js delete mode 100644 vdoing/package.json delete mode 100644 vdoing/styles/arrow.styl delete mode 100644 vdoing/styles/code-theme.styl delete mode 100644 vdoing/styles/code.styl delete mode 100644 vdoing/styles/config.styl delete mode 100644 vdoing/styles/custom-blocks.styl delete mode 100644 vdoing/styles/index.styl delete mode 100644 vdoing/styles/markdown-container.styl delete mode 100644 vdoing/styles/mobile.styl delete mode 100644 vdoing/styles/palette.styl delete mode 100644 vdoing/styles/toc.styl delete mode 100644 vdoing/styles/wrapper.styl delete mode 100644 vdoing/templates/dev.html delete mode 100644 vdoing/templates/ssr.html delete mode 100644 vdoing/types/index.ts delete mode 100644 vdoing/util/index.js delete mode 100644 vdoing/util/postData.js diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 978ddbf..c12f0ac 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -3,8 +3,8 @@ const plugins = require('./config/plugins.js'); const themeConfig = require('./config/themeConfig.js'); module.exports = { - // theme: 'vdoing', // 使用npm包主题 - theme: require.resolve('../../vdoing'), // 使用本地主题包 + theme: 'vdoing', // 使用npm包主题 + // theme: require.resolve('../../vdoing'), // 使用本地主题包 title: "Go-Ldap-Admin", description: '基于Go+Vue实现的openLDAP后台管理项目', base: '/', // 格式:'/<仓库名>/', 默认'/' diff --git "a/docs/01.\351\241\271\347\233\256\347\233\270\345\205\263/11.\345\256\211\350\243\205\345\205\245\351\227\250/01.docker-compose\345\234\250\346\234\254\345\234\260\345\277\253\351\200\237\346\213\211\350\265\267\346\265\213\350\257\225\347\216\257\345\242\203.md" "b/docs/01.\351\241\271\347\233\256\347\233\270\345\205\263/11.\345\256\211\350\243\205\345\205\245\351\227\250/01.docker-compose\345\234\250\346\234\254\345\234\260\345\277\253\351\200\237\346\213\211\350\265\267\346\265\213\350\257\225\347\216\257\345\242\203.md" index e556a56..1e3ca07 100644 --- "a/docs/01.\351\241\271\347\233\256\347\233\270\345\205\263/11.\345\256\211\350\243\205\345\205\245\351\227\250/01.docker-compose\345\234\250\346\234\254\345\234\260\345\277\253\351\200\237\346\213\211\350\265\267\346\265\213\350\257\225\347\216\257\345\242\203.md" +++ "b/docs/01.\351\241\271\347\233\256\347\233\270\345\205\263/11.\345\256\211\350\243\205\345\205\245\351\227\250/01.docker-compose\345\234\250\346\234\254\345\234\260\345\277\253\351\200\237\346\213\211\350\265\267\346\265\213\350\257\225\347\216\257\345\242\203.md" @@ -22,7 +22,7 @@ permalink: /pages/f081dc/ | Service | Port(宿主机端口:容器端口) | | :-----------: | :-----------------------: | -| MySQL | `3307:3306` | +| MySQL | `3306:3306` | | openLDAP | `389:389` | | phpldapadmin | `8091:80` | | go-ldap-admin | `8888:8888` | @@ -73,7 +73,7 @@ services: - ./data/openldap/database:/var/lib/ldap - ./data/openldap/config:/etc/ldap/slapd.d ports: - - 388:389 + - 389:389 networks: - go-ldap-admin @@ -150,7 +150,7 @@ services: hostname: go-ldap-admin-mysql restart: always ports: - - '3307:3306' + - '3306:3306' environment: TZ: Asia/Shanghai MYSQL_ROOT_PASSWORD: 123456 @@ -176,7 +176,7 @@ services: - ./data/openldap/database:/var/lib/ldap - ./data/openldap/config:/etc/ldap/slapd.d ports: - - 388:389 + - 389:389 networks: - go-ldap-admin @@ -253,7 +253,7 @@ services: - ./data/openldap/database:/var/lib/ldap - ./data/openldap/config:/etc/ldap/slapd.d ports: - - 388:389 + - 389:389 networks: - go-ldap-admin diff --git a/vdoing/LICENSE b/vdoing/LICENSE deleted file mode 100644 index 16d6732..0000000 --- a/vdoing/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-present gaoyi(Evan) Xu - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vdoing/README.md b/vdoing/README.md deleted file mode 100644 index 9d54bed..0000000 --- a/vdoing/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# vuepress-theme-vdoing - -vuepress-theme-vdoing for vuepress - -一个基于VuePress的 知识管理兼博客 主题。 - -[More](https://github.com/xugaoyi/vuepress-theme-vdoing#readme). diff --git a/vdoing/components/AlgoliaSearchBox.vue b/vdoing/components/AlgoliaSearchBox.vue deleted file mode 100644 index f191f35..0000000 --- a/vdoing/components/AlgoliaSearchBox.vue +++ /dev/null @@ -1,166 +0,0 @@ - - - - - diff --git a/vdoing/components/ArchivesPage.vue b/vdoing/components/ArchivesPage.vue deleted file mode 100644 index 9ee64be..0000000 --- a/vdoing/components/ArchivesPage.vue +++ /dev/null @@ -1,207 +0,0 @@ - - - - - diff --git a/vdoing/components/ArticleInfo.vue b/vdoing/components/ArticleInfo.vue deleted file mode 100644 index a7a2a07..0000000 --- a/vdoing/components/ArticleInfo.vue +++ /dev/null @@ -1,203 +0,0 @@ - - - - - diff --git a/vdoing/components/BloggerBar.vue b/vdoing/components/BloggerBar.vue deleted file mode 100644 index 71ca215..0000000 --- a/vdoing/components/BloggerBar.vue +++ /dev/null @@ -1,76 +0,0 @@ - - - - - diff --git a/vdoing/components/BodyBgImg.vue b/vdoing/components/BodyBgImg.vue deleted file mode 100644 index 97b6b55..0000000 --- a/vdoing/components/BodyBgImg.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - - - diff --git a/vdoing/components/Buttons.vue b/vdoing/components/Buttons.vue deleted file mode 100644 index da2fbb4..0000000 --- a/vdoing/components/Buttons.vue +++ /dev/null @@ -1,264 +0,0 @@ - - - - - diff --git a/vdoing/components/Catalogue.vue b/vdoing/components/Catalogue.vue deleted file mode 100644 index 968b6d5..0000000 --- a/vdoing/components/Catalogue.vue +++ /dev/null @@ -1,232 +0,0 @@ - - - - - diff --git a/vdoing/components/CategoriesBar.vue b/vdoing/components/CategoriesBar.vue deleted file mode 100644 index aaa9b4d..0000000 --- a/vdoing/components/CategoriesBar.vue +++ /dev/null @@ -1,114 +0,0 @@ - - - - - diff --git a/vdoing/components/CategoriesPage.vue b/vdoing/components/CategoriesPage.vue deleted file mode 100644 index 855a0a9..0000000 --- a/vdoing/components/CategoriesPage.vue +++ /dev/null @@ -1,140 +0,0 @@ - - - - - diff --git a/vdoing/components/DropdownLink.vue b/vdoing/components/DropdownLink.vue deleted file mode 100644 index 7e8bd9e..0000000 --- a/vdoing/components/DropdownLink.vue +++ /dev/null @@ -1,228 +0,0 @@ - - - - - diff --git a/vdoing/components/DropdownTransition.vue b/vdoing/components/DropdownTransition.vue deleted file mode 100644 index 8b1b4b1..0000000 --- a/vdoing/components/DropdownTransition.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - - - diff --git a/vdoing/components/Footer.vue b/vdoing/components/Footer.vue deleted file mode 100644 index 1b5e5c0..0000000 --- a/vdoing/components/Footer.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - - - diff --git a/vdoing/components/Home.vue b/vdoing/components/Home.vue deleted file mode 100644 index 7eececa..0000000 --- a/vdoing/components/Home.vue +++ /dev/null @@ -1,542 +0,0 @@ - - - - - diff --git a/vdoing/components/MainLayout.vue b/vdoing/components/MainLayout.vue deleted file mode 100644 index 40dc89b..0000000 --- a/vdoing/components/MainLayout.vue +++ /dev/null @@ -1,64 +0,0 @@ - - diff --git a/vdoing/components/NavLink.vue b/vdoing/components/NavLink.vue deleted file mode 100644 index 93feac7..0000000 --- a/vdoing/components/NavLink.vue +++ /dev/null @@ -1,54 +0,0 @@ - - - diff --git a/vdoing/components/NavLinks.vue b/vdoing/components/NavLinks.vue deleted file mode 100644 index 7be2ca3..0000000 --- a/vdoing/components/NavLinks.vue +++ /dev/null @@ -1,154 +0,0 @@ - - - - - diff --git a/vdoing/components/Navbar.vue b/vdoing/components/Navbar.vue deleted file mode 100644 index 2fb8bda..0000000 --- a/vdoing/components/Navbar.vue +++ /dev/null @@ -1,141 +0,0 @@ - - - - - diff --git a/vdoing/components/Page.vue b/vdoing/components/Page.vue deleted file mode 100644 index 5d0865c..0000000 --- a/vdoing/components/Page.vue +++ /dev/null @@ -1,218 +0,0 @@ - - - - - diff --git a/vdoing/components/PageEdit.vue b/vdoing/components/PageEdit.vue deleted file mode 100644 index 8ddafab..0000000 --- a/vdoing/components/PageEdit.vue +++ /dev/null @@ -1,168 +0,0 @@ - - - diff --git a/vdoing/components/PageNav.vue b/vdoing/components/PageNav.vue deleted file mode 100644 index b6b2a86..0000000 --- a/vdoing/components/PageNav.vue +++ /dev/null @@ -1,237 +0,0 @@ - - - diff --git a/vdoing/components/Pagination.vue b/vdoing/components/Pagination.vue deleted file mode 100644 index 0a65cd0..0000000 --- a/vdoing/components/Pagination.vue +++ /dev/null @@ -1,240 +0,0 @@ - - - - - diff --git a/vdoing/components/PostList.vue b/vdoing/components/PostList.vue deleted file mode 100644 index dc2eb32..0000000 --- a/vdoing/components/PostList.vue +++ /dev/null @@ -1,260 +0,0 @@ - - - - - diff --git a/vdoing/components/RightMenu.vue b/vdoing/components/RightMenu.vue deleted file mode 100644 index 09b2b68..0000000 --- a/vdoing/components/RightMenu.vue +++ /dev/null @@ -1,149 +0,0 @@ - - - - - diff --git a/vdoing/components/Sidebar.vue b/vdoing/components/Sidebar.vue deleted file mode 100644 index 5e5c9c0..0000000 --- a/vdoing/components/Sidebar.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - - - diff --git a/vdoing/components/SidebarButton.vue b/vdoing/components/SidebarButton.vue deleted file mode 100644 index 706adf1..0000000 --- a/vdoing/components/SidebarButton.vue +++ /dev/null @@ -1,64 +0,0 @@ - - - diff --git a/vdoing/components/SidebarGroup.vue b/vdoing/components/SidebarGroup.vue deleted file mode 100644 index 3ef66e2..0000000 --- a/vdoing/components/SidebarGroup.vue +++ /dev/null @@ -1,128 +0,0 @@ - - - - - diff --git a/vdoing/components/SidebarLink.vue b/vdoing/components/SidebarLink.vue deleted file mode 100644 index d1e524a..0000000 --- a/vdoing/components/SidebarLink.vue +++ /dev/null @@ -1,130 +0,0 @@ - - - diff --git a/vdoing/components/SidebarLinks.vue b/vdoing/components/SidebarLinks.vue deleted file mode 100644 index 678c94b..0000000 --- a/vdoing/components/SidebarLinks.vue +++ /dev/null @@ -1,93 +0,0 @@ - - - diff --git a/vdoing/components/TagsBar.vue b/vdoing/components/TagsBar.vue deleted file mode 100644 index 9f4072d..0000000 --- a/vdoing/components/TagsBar.vue +++ /dev/null @@ -1,110 +0,0 @@ - - - - - diff --git a/vdoing/components/TagsPage.vue b/vdoing/components/TagsPage.vue deleted file mode 100644 index fdeab56..0000000 --- a/vdoing/components/TagsPage.vue +++ /dev/null @@ -1,125 +0,0 @@ - - - - - diff --git a/vdoing/components/UpdateArticle.vue b/vdoing/components/UpdateArticle.vue deleted file mode 100644 index ae0270f..0000000 --- a/vdoing/components/UpdateArticle.vue +++ /dev/null @@ -1,162 +0,0 @@ - - - - - diff --git a/vdoing/enhanceApp.js b/vdoing/enhanceApp.js deleted file mode 100644 index d0166a0..0000000 --- a/vdoing/enhanceApp.js +++ /dev/null @@ -1,47 +0,0 @@ -// 解决代码选项卡无法加载的问题 -import Vue from 'vue' -import CodeBlock from "@theme/global-components/CodeBlock.vue" -import CodeGroup from "@theme/global-components/CodeGroup.vue" -// Register the Vue global component -Vue.component(CodeBlock) -Vue.component(CodeGroup) - -// 注:此文件在浏览器端运行 -import postsMixin from '@theme/mixins/posts' -export default ({ - Vue, // VuePress 正在使用的 Vue 构造函数 - options, // 附加到根实例的一些选项 - router, // 当前应用的路由实例 - siteData // 站点元数据 -}) => { - // 修复ISO8601时间格式为普通时间格式,以及添加作者信息 - siteData.pages.map(item => { - const { frontmatter: { date, author } } = item - if (typeof date === 'string' && date.charAt(date.length - 1) === 'Z') { - item.frontmatter.date = repairUTCDate(date) - } - if (author) { - item.author = author - } else { - if (siteData.themeConfig.author) { - item.author = siteData.themeConfig.author - } - } - }) - - // 将对文章数据的处理结果混入Vue实例 - Vue.mixin(postsMixin) -} - - -// 修复ISO8601时间格式为普通时间格式 -function repairUTCDate(date) { - if (!(date instanceof Date)) { - date = new Date(date) - } - return `${date.getUTCFullYear()}-${zero(date.getUTCMonth() + 1)}-${zero(date.getUTCDate())} ${zero(date.getUTCHours())}:${zero(date.getUTCMinutes())}:${zero(date.getUTCSeconds())}`; -} -// 小于10补0 -function zero(d) { - return d.toString().padStart(2, '0') -} diff --git a/vdoing/global-components/Badge.vue b/vdoing/global-components/Badge.vue deleted file mode 100644 index c89600d..0000000 --- a/vdoing/global-components/Badge.vue +++ /dev/null @@ -1,44 +0,0 @@ - - - diff --git a/vdoing/global-components/CodeBlock.vue b/vdoing/global-components/CodeBlock.vue deleted file mode 100644 index 50cf503..0000000 --- a/vdoing/global-components/CodeBlock.vue +++ /dev/null @@ -1,38 +0,0 @@ - - - - - diff --git a/vdoing/global-components/CodeGroup.vue b/vdoing/global-components/CodeGroup.vue deleted file mode 100644 index 871c295..0000000 --- a/vdoing/global-components/CodeGroup.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - - - diff --git a/vdoing/index.js b/vdoing/index.js deleted file mode 100644 index d40b863..0000000 --- a/vdoing/index.js +++ /dev/null @@ -1,292 +0,0 @@ -const path = require('path') -const setFrontmatter = require('./node_utils/setFrontmatter') -const getSidebarData = require('./node_utils/getSidebarData') -const { createPage, deletePage } = require('./node_utils/handlePage') -const chalk = require('chalk') // 命令行打印美化 -const yaml = require('js-yaml') // yaml转js -const log = console.log - -// md容器名 -const CARD_LIST = 'cardList' -const CARD_IMG_LIST = 'cardImgList' - -// siteConfig base 配置 -let base = '' - - -// Theme API. -module.exports = (options, ctx) => { - const { sourceDir, themeConfig, siteConfig } = ctx - - // base路径 - base = siteConfig.base || '' - - // 自动设置front matter - setFrontmatter(sourceDir, themeConfig) - - // 自动生成结构化侧边栏 - const sidebar = themeConfig.sidebar - if (sidebar === 'structuring' || sidebar && sidebar.mode === 'structuring') { - const collapsable = themeConfig.sidebar.collapsable === false ? false : true - const sidebarData = getSidebarData(sourceDir, collapsable) - if (sidebarData) { - themeConfig.sidebar = sidebarData - log(chalk.blue('tip ') + chalk.green('add sidebar data. 成功生成侧边栏数据。')) - } else { - themeConfig.sidebar = 'auto' - log(chalk.yellow('warning: fail to add sidebar data, switch to "auto". 未能添加侧边栏数据,将切换为“auto”。')) - } - } - - // 分类页 - if (themeConfig.category !== false) { - createPage(sourceDir, 'categoriesPage') - } else { - deletePage(sourceDir, 'categoriesPage') - } - - // 标签页 - if (themeConfig.tag !== false) { - createPage(sourceDir, 'tagsPage') - } else { - deletePage(sourceDir, 'tagsPage') - } - - // 归档页 - if (themeConfig.archive !== false) { - createPage(sourceDir, 'archivesPage') - } else { - deletePage(sourceDir, 'archivesPage') - } - - // resolve algolia - const isAlgoliaSearch = ( - themeConfig.algolia - || Object - .keys(siteConfig.locales && themeConfig.locales || {}) - .some(base => themeConfig.locales[base].algolia) - ) - - const enableSmoothScroll = themeConfig.smoothScroll === true - - return { - alias() { - return { - '@AlgoliaSearchBox': isAlgoliaSearch - ? path.resolve(__dirname, 'components/AlgoliaSearchBox.vue') - : path.resolve(__dirname, 'noopModule.js') - } - }, - - plugins: [ - ['@vuepress/active-header-links', options.activeHeaderLinks], - '@vuepress/search', - '@vuepress/plugin-nprogress', - ['smooth-scroll', enableSmoothScroll], - - ['container', { - type: 'note', - defaultTitle: { - '/': '笔记', - '/en/': 'NOTE' - } - }], - ['container', { - type: 'tip', - defaultTitle: { - '/': '提示', - '/en/': 'TIP' - } - }], - ['container', { - type: 'warning', - defaultTitle: { - '/': '注意', - '/en/': 'WARNING' - } - }], - ['container', { - type: 'danger', - defaultTitle: { - '/': '警告', - '/en/': 'WARNING' - } - }], - ['container', { - type: 'right', - defaultTitle: '' - }], - ['container', { - type: 'theorem', - before: info => `

${info}

`, - after: '
' - }], - ['container', { - type: 'details', - before: info => `
${info ? `${info}` : ''}\n`, - after: () => '
\n', - defaultTitle: { - '/': '点击查看', - '/en/': 'DETAILS' - } - }], - - // 内容居中容器 - ['container', { - type: 'center', - before: info => `
`, - after: () => '
' - }], - - // 卡片列表 - [ - 'container', - { - type: CARD_LIST, - render: (tokens, idx) => { - // tokens 是整个md文件的虚拟dom结构数组 - // idx 是tokens中':::' 所在的索引,而且是当前指定type的':::',分别有开始和结束两次的idx - // if (tokens[idx].nesting === 1) { // 开头的 ':::' 标记 - // } else { // 结束的 ':::' 标记 - // } - // 注意:修改这里面的代码后需要在md文件保存一下才会重新执行渲染 - return renderCardList(tokens, idx, CARD_LIST) - } - }, - ], - - // 图文卡片列表 - [ - 'container', - { - type: CARD_IMG_LIST, - render: (tokens, idx) => { - return renderCardList(tokens, idx, CARD_IMG_LIST) - } - }, - ], - - - ] - } -} - - -// 渲染md容器的卡片列表 -function renderCardList(tokens, idx, type) { - const END_TYPE = `container_${type}_close`, - _tokens$idx = tokens[idx], - nesting = _tokens$idx.nesting, - info = _tokens$idx.info; - - if (nesting === 1) { // 渲染开头的 ':::' 标记 - let yamlStr = ''; - - for (let i = idx; i < tokens.length; i++) { - let _tokens$i = tokens[i], - type = _tokens$i.type, - content = _tokens$i.content, - _info = _tokens$i.info; - if (type === END_TYPE) break; // 遇到结束的 ':::' 时 - if (!content) continue; - if (type === 'fence' && _info === 'yaml') { // 是代码块类型,并且是yaml代码 - yamlStr = content - } - } - - if (yamlStr) { // 正确解析出yaml字符串后 - const dataObj = yaml.safeLoad(yamlStr) // 将yaml字符串解析成js对象 - let dataList = [] - let config = {} - - if (dataObj) { // 正确解析出数据对象 - if (Array.isArray(dataObj)) { - dataList = dataObj - } else { - config = dataObj.config - dataList = dataObj.data - } - } - - if (dataList && dataList.length) { // 有列表数据 - - // 每行显示几个 - let row = Number(info.split(' ').pop()) - if (!row || row > 4 || row < 1) { - row = 3 // 默认 3 - } - - let listDOM = '' - if (type === CARD_LIST) { // 普通卡片列表 - listDOM = getCardListDOM(dataList, row, config) - } else if (type === CARD_IMG_LIST) { // 卡片图片列表 - listDOM = getCardImgListDOM(dataList, row, config) - } - - return `
${listDOM}
` - } - } - } else { // 渲染':::' 结尾 - return '
' - } -} - - -// 将数据解析成DOM结构 - 普通卡片列表 -function getCardListDOM(dataList, row, config) { - const { target = '_blank' } = config - let listDOM = '' - dataList.forEach(item => { - listDOM += ` - <${item.link ? 'a href="' + withBase(item.link) + '" target="' + target + '"' : 'span'} class="card-item ${row ? 'row-' + row : ''}" - style="${item.bgColor ? 'background-color:' + item.bgColor + ';--randomColor:' + item.bgColor + ';' : '--randomColor: var(--bodyBg);'}${item.textColor ? 'color:' + item.textColor + ';' : ''}" - > - ${item.avatar ? '' : ''} -
-

${item.name}

-

${item.desc}

-
- - ` - }) - return listDOM -} - - -// 将数据解析成DOM结构 - 图文卡片列表 -function getCardImgListDOM(dataList, row, config) { - const { imgHeight = 'auto', objectFit = 'cover', lineClamp = 1, target = '_blank' } = config - - let listDOM = '' - dataList.forEach(item => { - listDOM += ` -
- -
- -
-
-

${item.name}

- ${item.desc ? `

${item.desc}

` : ''} -
- - ${item.avatar || item.author ? ``: ''} -
-
- ` - }) - return listDOM -} - -// 添加base路径 -function withBase(path) { - if (!path) return ''; - if (base && path.charAt(0) === '/') { - return base + path.slice(1); - } else { - return path; - } -} diff --git a/vdoing/layouts/404.vue b/vdoing/layouts/404.vue deleted file mode 100644 index c8b7672..0000000 --- a/vdoing/layouts/404.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - - - diff --git a/vdoing/layouts/Layout.vue b/vdoing/layouts/Layout.vue deleted file mode 100644 index 7361ef3..0000000 --- a/vdoing/layouts/Layout.vue +++ /dev/null @@ -1,379 +0,0 @@ - - - - - diff --git a/vdoing/mixins/posts.js b/vdoing/mixins/posts.js deleted file mode 100644 index 2dec307..0000000 --- a/vdoing/mixins/posts.js +++ /dev/null @@ -1,21 +0,0 @@ -import { filterPosts, sortPosts, sortPostsByDate, groupPosts, categoriesAndTags } from '../util/postData' - -export default { - computed: { - $filterPosts () { // 过滤非文章页和首页的文章数据 - return filterPosts(this.$site.pages) - }, - $sortPosts () { // 按置顶和时间排序的文章数据 - return sortPosts(this.$filterPosts) - }, - $sortPostsByDate () { // 仅按时间排序的文章数据 - return sortPostsByDate(this.$filterPosts) - }, - $groupPosts () { // 按分类和标签分组的文章数据 - return groupPosts(this.$sortPosts) - }, - $categoriesAndTags () { // 所有分类和标签数据 - return categoriesAndTags(this.$groupPosts) - } - } -} diff --git a/vdoing/mixins/titleBadge.js b/vdoing/mixins/titleBadge.js deleted file mode 100644 index 224f0c0..0000000 --- a/vdoing/mixins/titleBadge.js +++ /dev/null @@ -1,28 +0,0 @@ -export default { - data () { - return { - badges: [ - 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAABGpJREFUSA3tVVtoXFUU3fvOI53UlmCaKIFmwEhsE7QK0ipFEdHEKpXaZGrp15SINsXUWvBDpBgQRKi0+KKoFeJHfZA+ED9KKoIU2gYD9UejTW4rVIzm0VSTziPzuNu1z507dibTTjL4U/DAzLn3nL3X2o91ziX6f9wMFdh6Jvbm9nNSV0msViVO6tN1Rm7NMu2OpeJ9lWBUTDxrJbYTS0hInuwciu9eLHlFxCLCZEk3MegsJmZ5K/JD6t7FkFdEvGUo1g7qJoG3MHImqRIn8/nzY1K9UPKKiJmtnUqHVE3Gbuay6vJE/N2FEmuxFjW2nUuE0yQXRRxLiTUAzs36zhZvOXJPdX850EVnnLZkB8prodQoM5JGj7Xk2mvC7JB8tG04Ef5PiXtG0UtxupRQSfTnBoCy554x18yJHI6I+G5Eru4LHmPJZEQsrvPUbMiA8G/WgMK7w7I+ez7++o2ANfbrjvaOl1tFMs+htG3IrZH9/hDX1Pr8Tc0UvH8tcX29KzAgIGcEkINyW5BF9x891hw6VYqgJHEk0huccS7vh3C6gTiODL+26huuBtbct8eZnqLML8PkxGYpuPZBqtqwkSjgc4mB5gbgig5i+y0UDK35LMxXisn9xQtK+nd26gTIHsHe/oblK/b29fUmN/8Y+9jAQrnBp56m1LcDlDp9irKTExSKduXJVWSqdBMA08pEJnEIOB3FPPMybu/oeV8zFeYN3xx576Q6RH+VmplE4ncQV5v+5rzSoyOU7PuEAg8g803PwBJ0CExno/jcMbN8tONYeOmHiuUNryvm3fRUy4tMPVLdAGkUhNWuggGrJcXPv+ouCjz0MKUHz1J2/E8IC9nqTabcxgaBYM0hPhD5Y65FsbxRQKxCQrDjDctW7PUM3HuZunFyifSAqEfuzCp48Il24luWUWZoyJCaPR82jE0+kFA643wRFVni4RYSq3ohJO2pZ7B5dO4xkDWbEpossJPLSrPjYID8rS2UHTlvyNxqIGsg674XJJ7vnh5L7PNwC4hh2sjCI96mzszOTpxLF0T7l88Yz7lAuK6OnL8gXLOnTvpzSb22YG8W7us3jSebFHeeqnXRG1vt+MoUM84LQIBmMsCTAcOauTh0T0l0neQK7m2bLMt2mGxU3HYssS0J2cdv5wljlPsrIuZLAG/2DOZIXgCYT8uMGZN+e2kSirfxZOPCsC0f24nTZzspnVn9VePS1Z5vubmAGGXG8ZFno9Hel0yfA5ZPhF7Dh972BQJ2qCpgH67lmWtBYbvk6sz02wjky2vXyz0XErP/kFB619js1BtwfOV4OPRqOQBjy3Qbk18vigUPPSD5ceHnwck7W9bhAqZdd7SuG7w4/P2F/GaJh8c7e9qgow+Q7cGBo+98WsLkuktFqiZabtXuQTu/Y5ETbR0v7tNSFnvrmu6pjdoan2KjMu8q/Hmj1EfCO2ZGfEIbIXKUlw8qaX9/b2oeSJmFksSeT/Fn0V3nSypChh4Gjh74ybO9aeZ/AN2dwciu2/MhAAAAAElFTkSuQmCC', - 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAABH1JREFUSA3tVl1oHFUUPmdmd2ltklqbpJDiNnXFmgbFktho7YMPNiJSSZM0+CAYSkUELVhM6YuwIPpgoOKDqOBDC0XE2CQoNtQXBUFTTcCi+Wlh1V2TQExsUzcltd3M9Tt3ZjZzZ2fT+OJTL8yeM+eee757fmeJbq//KQL8X3DUSFOcfr7cRsRtxNQMWueeVzOkaITIGqQHNg5y8+jNW9ldM7A6nTpAjuolUikAwq7CE3WcM2RRDz+XGVgN3FptU/aUSlvq9Pa3iZ1+sgAqJyyAFqkipd9dqiwHF3P65YycLWc/6sqGrvoEoIp6DOFaX5h6+dnfjkWprwqsPk0dUGq5vySwDImC10KxFHgGL1SWoc92O3eVht09qdXNH11I2SsTsJYqMWzihqGMi+A+Garf3BAuuLI5oGlULyNfyB/HYNujwktOfRrMr5t77NmevqaUopx0grnKAyvVpmwUDB4x6FPXuGvYLTDwWsejwgtgkYKPqRJg8SV6xaiZ3ZTppGneS4yfH5/66fZSDHv+QZci/+h5c5UHtpy67JUqGppM0sh0Nc1dW6/N1W5Yoqat8/TU/VnadmdeW2PLLSyh0cvxBs3KbqTmwYPpxN4do/mzE8nEpvX/UMu2Wbp74zUAK5q6WkHns7V0eWkdPbPzd3rxkTGybadYySumVzhcaJFbs5UrEkQ/+CK8gF5dnh/6ciIZ73gwQ927L1IitoxKLXYP3SjYdOrHHfTZhRRlFyrorafPk20B3HPD1y2G3qKZME5Jcf3t/HUC13/8tSd++vqFveMUTwAUxSUFI1QekR1+bIze3D9MF2aq6cPvG72CgnldWCFqyRw3lwH8ZMerjTD9ElRO7Gv44wNpC90aASqGfVlz/Rx17srQ57/UU26hkhQqUB7dBR71WmzQhHUnblGmVOEw0jhbV1n9OlXUDCIRGaNV5Jp43N516fN7JmnTHdfp7Hgy0luO4aMhtkLL8Bi3bUWYvzh5Mn1dTxrL6QmGuRhGL/TiTTxRoEdTszSaq9GR0NGA3KdkOz3hqSV3MIDhQ5IVX/Ivx3umBti2es2h4eZby7x8br1rkf7Mo90AqC8aQ3sJeNzqFRu+vSANAQe3PL7l0HGOAdwDCeZYvNKeoZp1Qfs6Aipndh86HmFRi0LAnEO47wsqM6cdfjh3jBPUzhZy7nvlUfFsamED1VQt6aISHVymXZ/B2aCtIG8AI8xfobj2d3en1wWVhOeHELKmLQ1s211s88comkv4UCwWyF787mJdYXtNfhKAXVqnKTq8QZvGAGGOfaTo5pGZ/PwbUCr5+DPr/1J92JNHr9aOl/F3iI5+O1nfybsGxoimvZ3ViWSluDITw3P37mypheDIPY0tw7+O/5ApbkYw+zpfaUVu32Pi98+defdUhEpZkRFq0aqyNh9FuL9hpYbEm6iwi0z2REd09ZmyENEbuhjDWzKvZXTqKYaBIr3tt5kuPtQBZFvEUwHt60vfCNu41XsksH9Ij1BMMz1Y0OOunHNShFIP5868g5zeXmuLwL9T4b6Q2+KejgAAAABJRU5ErkJggg==', - 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAABKFJREFUSA3tVl1oFVcQnrMbrak3QUgkya1akpJYcrUtIqW1JvFBE9LiQ5v6JmJpolbMg32rVrhgoYK0QiMY6i9Y6EMaW5D+xFJaTYItIuK2Kr3+BJNwkxBj05sQY3b3nM6cs2dv9t7NT/vQJw/sndk5M/PNzJkzewGerP+pAmy+ON8lLzUJgA8ZYxYIYZmGYRnctDaWvJJAmTtfP1pvXsBCCPP8QFcCaRkZYACgDZFO4stNIcBCajEOlmmC9XpJ9bAGCaPaPmzPl32dvLSVu3BWCTQs0XQQ6g0DYgwLIoAZbBCdW/i+781o1VVlm/410mw4h06Y7bIPHNyWDyL4FHkX03Q8SrzNhZTZriieckWt7cL6MM85YcLpsi/7O9/iXFT6MswI0DmmpkSaJ0qLxFIm3+i1THHB3zmBH3PYx9CcykcLOeQVVa7QtdxTgQgEleX2AjHYfwA+2ddV77ruGoJUbhGDI09YSNXyMpUt5ylOzxgbUmtOp7NmbNt8v3arjTBfYELmLUV+M+nSawNNAUqpT3ClJWg5I3BLT+cGW/DXNGCa6tx1aakCGEigArTn4TDIPdrXXYKCZNrHLMCOEPvHBlLQ99s9eHB7EB6NTki73CVPQ2F5MSx/uRQixfmq7rK0wYD8w8E905bnPDfwoWs/rfv93NWN/ZfvwsLIU7A09gxECyISeGJkHAau98L97tuw7NXnoPyNF8FcYGLGKsOs0mN3OEyec9esGW/ZEl945dTP34wlR2FZVQWU1q0Cw8Tr7p+hgLLNL0FPxx/Q35mA8aEUrH6nCgwEl0tn7wUiZYJnNRh6DK4UH/k0lfyrsBKdPVv/AriGIQcEDQZ65LBAGe2Rzui9Ybjz7XUppz1/uKBbyVPGkN3ZAeC6hr0x7Nr38N5+EqkoOm17xpoqR9ohQF55ERSvr4Dkr3chNfC3DMzGJlNBElW8w9nsGQvhNGIzDkXzCg8cLK951xHsFBlTJspJNi3ZFIMF2AeDV3q8DNOB+YHi6QTrChDIWDBRi5U5f+ZMfJLu3ccrqxtdxk4SKH336LFxSmkqefwU5T8fhdSdQf9IVKD6aNiwI/hnmcAZ91isYMJIaCUCx9W098+LgruikeTqzqqxKPUwqJyCPJiyemVVZBOijDGjD38Os0jOiSPL1z3SPjXNANbiNPXAdzTfukjjuknNBbyz3nwgTd3AVFqUJ5hpHlq9MveLnWwttUfoygBmvVjuikxND3znrhsELnZk7k+OjIGxeNEkomyLVta0xxn+HZhjBc4YZ/AFjHjz9u3xRZl2BN4aq9nFwWh16IrQ1aHHEd3j1+4/dB9OtH4e29A2H1DyHQRmOSfQZ1Fy7MHBTGB6J/Djq6p3OxyO2cB+4Car7v/o3GXgfAkj23+x9ID1Teoamo/SXcbvSf2PX7Vc8DdCmE1vN9di+32P9/5YR3vLnhCVGUWBjEkr3yh4H8v9CzmsbdhzOKzsJKM90iFdaTMjRPhGVsakRvOaRidljo6H6G7j+ctrJpsP+4COhDIl0La2+FS4+5mlocBaXY5QnGZysIBYoeSsl5qQzrSj/cgNrfuEzlWBfwA+EjrZyWUvpAAAAABJRU5ErkJggg==' - ], - currentBadge: '' - } - }, - created () { - if (this.$themeConfig.titleBadgeIcons) { - this.badges = this.$themeConfig.titleBadgeIcons - } - this.currentBadge = this.getBadge() - }, - watch: { - '$route.path' () { - this.currentBadge = this.getBadge() - } - }, - methods: { - getBadge () { - return this.badges[Math.floor(Math.random() * this.badges.length)] - } - } -} diff --git a/vdoing/node_utils/getSidebarData.js b/vdoing/node_utils/getSidebarData.js deleted file mode 100644 index ab52ffd..0000000 --- a/vdoing/node_utils/getSidebarData.js +++ /dev/null @@ -1,185 +0,0 @@ -const fs = require('fs'); // 文件模块 -const path = require('path'); // 路径模块 -const chalk = require('chalk') // 命令行打印美化 -const matter = require('gray-matter'); // front matter解析器 -const log = console.log - -let catalogueData = {}; // 目录页数据 - -/** - * 生成侧边栏数据 - * @param {String} sourceDir .md文件所在源目录(一般是docs目录) - * @param {Boolean} collapsable 是否可折叠 - */ -function createSidebarData(sourceDir, collapsable) { - const sidebarData = {}; - const tocs = readTocs(sourceDir); - tocs.forEach(toc => { // toc是每个目录的绝对路径 - - if (toc.substr(-6) === '_posts') { // 碎片化文章 - - // 注释说明:碎片化文章不需要生成结构化侧边栏 2020.05.01 - // const sidebarArr = mapTocToPostSidebar(toc); - // sidebarData[`/${path.basename(toc)}/`] = sidebarArr - - } else { - const sidebarObj = mapTocToSidebar(toc, collapsable); - if (!sidebarObj.sidebar.length) { - log(chalk.yellow(`warning: 该目录 "${toc}" 内部没有任何文件或文件序号出错,将忽略生成对应侧边栏`)) - return; - } - sidebarData[`/${path.basename(toc)}/`] = sidebarObj.sidebar - sidebarData.catalogue = sidebarObj.catalogueData - } - }) - - return sidebarData -} - -module.exports = createSidebarData; - - -/** - * 读取指定目录下的文件绝对路径 - * @param {String} root 指定的目录 -*/ -function readTocs(root) { - const result = []; - const files = fs.readdirSync(root); // 读取目录,返回数组,成员是root底下所有的目录名 (包含文件夹和文件) - files.forEach(name => { - const file = path.resolve(root, name); // 将路径或路径片段的序列解析为绝对路径 - if (fs.statSync(file).isDirectory() && name !== '.vuepress' && name !== '@pages') { // 是否为文件夹目录,并排除.vuepress文件夹 - result.push(file); - } - }) - return result; -} - - -/** - * 将碎片化文章目录(_posts)映射为对应的侧边栏配置数据 - * @param {String} root - */ -function mapTocToPostSidebar(root) { - let postSidebar = [] // 碎片化文章数据 - const files = fs.readdirSync(root); // 读取目录(文件和文件夹),返回数组 - - files.forEach(filename => { - const file = path.resolve(root, filename); // 方法:将路径或路径片段的序列解析为绝对路径 - const stat = fs.statSync(file); // 文件信息 - - const fileNameArr = filename.split('.'); - if (fileNameArr.length > 2) { - log(chalk.yellow(`warning: 该文件 "${file}" 在_posts文件夹中,不应有序号,且文件名中间不应有'.'`)) - return - } - if (stat.isDirectory()) { // 是文件夹目录 - // log(chalk.yellow(`warning: 该目录 "${file}" 内文件无法生成侧边栏,_posts文件夹里面不能有二级目录。`)) - return - } - - let [title, type] = filename.split('.'); - if (type !== 'md') { - log(chalk.yellow(`warning: 该文件 "${file}" 非.md格式文件,不支持该文件类型`)) - return; - } - - const contentStr = fs.readFileSync(file, 'utf8') // 读取md文件内容,返回字符串 - const { data } = matter(contentStr, {}) // 解析出front matter数据 - const { permalink = '', titleTag = '' } = data || {} - if (data.title) { - title = data.title - } - const item = [filename, title, permalink] - if (titleTag) { - item.push(titleTag) - } - postSidebar.push(item); // [<路径>, <标题>, <永久链接>, ] - }) - - return postSidebar -} - - -/** - * 将目录映射为对应的侧边栏配置数据 - * @param {String} root - * @param {Boolean} collapsable - * @param {String} prefix - */ - -function mapTocToSidebar(root, collapsable, prefix = '') { - let sidebar = []; // 结构化文章侧边栏数据 - const files = fs.readdirSync(root); // 读取目录(文件和文件夹),返回数组 - - files.forEach(filename => { - const file = path.resolve(root, filename); // 方法:将路径或路径片段的序列解析为绝对路径 - const stat = fs.statSync(file); // 文件信息 - if (filename === '.DS_Store') { // 过滤.DS_Store文件 - return - } - // let [order, title, type] = filename.split('.'); - - const fileNameArr = filename.split('.') - const isDir = stat.isDirectory() - let order = '', title = '', type = ''; - if (fileNameArr.length === 2) { - order = fileNameArr[0]; - title = fileNameArr[1]; - } else { - const firstDotIndex = filename.indexOf('.'); - const lastDotIndex = filename.lastIndexOf('.'); - order = filename.substring(0, firstDotIndex); - type = filename.substring(lastDotIndex + 1); - if (isDir) { - title = filename.substring(firstDotIndex + 1); - } else { - title = filename.substring(firstDotIndex + 1, lastDotIndex); - } - } - - order = parseInt(order, 10); - if (isNaN(order) || order < 0) { - log(chalk.yellow(`warning: 该文件 "${file}" 序号出错,请填写正确的序号`)) - return; - } - if (sidebar[order]) { // 判断序号是否已经存在 - log(chalk.yellow(`warning: 该文件 "${file}" 的序号在同一级别中重复出现,将会被覆盖`)) - } - if (isDir) { // 是文件夹目录 - sidebar[order] = { - title, - collapsable, // 是否可折叠,默认true - children: mapTocToSidebar(file, collapsable, prefix + filename + '/').sidebar // 子栏路径添加前缀 - } - } else { // 是文件 - if (type !== 'md') { - log(chalk.yellow(`warning: 该文件 "${file}" 非.md格式文件,不支持该文件类型`)) - return; - } - const contentStr = fs.readFileSync(file, 'utf8') // 读取md文件内容,返回字符串 - const { data } = matter(contentStr, {}) // 解析出front matter数据 - const { permalink = '', titleTag = '' } = data || {} - - // 目录页对应的永久链接,用于给面包屑提供链接 - const { pageComponent } = data - if (pageComponent && pageComponent.name === "Catalogue") { - catalogueData[title] = permalink - } - - if (data.title) { - title = data.title - } - const item = [prefix + filename, title, permalink] - if (titleTag) item.push(titleTag) - sidebar[order] = item; // [<路径>, <标题>, <永久链接>, ] - - } - }) - - sidebar = sidebar.filter(item => item !== null && item !== undefined); - return { - sidebar, - catalogueData - }; -} diff --git a/vdoing/node_utils/handlePage.js b/vdoing/node_utils/handlePage.js deleted file mode 100644 index 5268653..0000000 --- a/vdoing/node_utils/handlePage.js +++ /dev/null @@ -1,82 +0,0 @@ -// 生成或删除页面(分类页、标签页、归档页...) - -const fs = require('fs'); // 文件模块 -const path = require('path'); // 路径模块 -const chalk = require('chalk') // 命令行打印美化 -const { type } = require('./modules/fn'); -const log = console.log - -function createPage (sourceDir, page) { - const dirPath = path.join(sourceDir, '@pages') // 生成的文件夹路径 - - // 文件夹不存在时 - if (!fs.existsSync(dirPath)) { - fs.mkdirSync(dirPath) // 创建文件夹 - } - - const pagePath = path.join(dirPath, `${page}.md`) // 生成的文件路径 - - // 文件已经存在时跳出 - if (fs.existsSync(pagePath)) { - return - } - - // 注意:反引号字符串的格式会映射到文件 - let content = '' - if (page.indexOf('categories') > -1) { - content = `--- -categoriesPage: true -title: 分类 -permalink: /categories/ -article: false ----` - } else if (page.indexOf('tags') > -1) { - content = `--- -tagsPage: true -title: 标签 -permalink: /tags/ -article: false ----` - } else if (page.indexOf('archives') > -1) { - content = `--- -archivesPage: true -title: 归档 -permalink: /archives/ -article: false ----` - } - - if (content) { - fs.writeFileSync(pagePath, content) - log(chalk.blue('tip ') + chalk.green(`create page(生成页面): ${pagePath}`)) - } -} - -// 删除页面文件 -function deletePage (sourceDir, page) { - const dirPath = path.join(sourceDir, '@pages') // 文件夹路径 - const pagePath = path.join(dirPath, `${page}.md`) // 文件路径 - - // 文件是否存在 - if (fs.existsSync(pagePath)) { - fs.unlinkSync(pagePath) - log(chalk.blue('tip ') + chalk.green(`delete page(删除页面): ${pagePath}`)) - } - deleteDir(dirPath) -} - -// 删除文件夹 -function deleteDir (dirPath) { - if (fs.existsSync(dirPath)) { - const files = fs.readdirSync(dirPath) - if (type(files) === 'array' && files.length === 0) { - fs.rmdirSync(dirPath) - log(chalk.blue('tip ') + chalk.green(`delete dir(删除目录): ${dirPath}`)) - } - } -} - -module.exports = { - createPage, - deletePage -} diff --git a/vdoing/node_utils/modules/fn.js b/vdoing/node_utils/modules/fn.js deleted file mode 100644 index 1528498..0000000 --- a/vdoing/node_utils/modules/fn.js +++ /dev/null @@ -1,21 +0,0 @@ -// 类型判断 -exports.type = function (o) { - var s = Object.prototype.toString.call(o) - return s.match(/\[object (.*?)\]/)[1].toLowerCase() -} - -// 修复date时区格式的问题 -exports.repairDate = function (date) { - date = new Date(date); - return `${date.getUTCFullYear()}-${zero(date.getUTCMonth() + 1)}-${zero(date.getUTCDate())} ${zero(date.getUTCHours())}:${zero(date.getUTCMinutes())}:${zero(date.getUTCSeconds())}`; -} - -// 日期的格式 -exports.dateFormat = function (date) { - return `${date.getFullYear()}-${zero(date.getMonth() + 1)}-${zero(date.getDate())} ${zero(date.getHours())}:${zero(date.getMinutes())}:${zero(date.getSeconds())}` -} - -// 小于10补0 -function zero (d) { - return d.toString().padStart(2, '0') -} diff --git a/vdoing/node_utils/modules/readFileList.js b/vdoing/node_utils/modules/readFileList.js deleted file mode 100644 index 4e8d20d..0000000 --- a/vdoing/node_utils/modules/readFileList.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 读取所有md文件数据 - */ -const fs = require('fs'); // 文件模块 -const path = require('path'); // 路径模块 -const chalk = require('chalk') // 命令行打印美化 -const log = console.log - -function readFileList(dir, filesList = []) { - const files = fs.readdirSync(dir); - files.forEach((item, index) => { - let filePath = path.join(dir, item); - const stat = fs.statSync(filePath); - if (stat.isDirectory() && item !== '.vuepress' && item !== '@pages') { - readFileList(path.join(dir, item), filesList); //递归读取文件 - } else { - if (path.basename(dir) !== 'docs') { // 过滤docs目录级下的文件 - - const filename = path.basename(filePath) - const fileNameArr = filename.split('.') - const firstDotIndex = filename.indexOf('.'); - const lastDotIndex = filename.lastIndexOf('.'); - - let name = null, type = null; - if (fileNameArr.length === 2) { // 没有序号的文件 - name = fileNameArr[0] - type = fileNameArr[1] - } else if (fileNameArr.length >= 3) { // 有序号的文件(或文件名中间有'.') - name = filename.substring(firstDotIndex + 1, lastDotIndex) - type = filename.substring(lastDotIndex + 1) - } - - if (type === 'md') { // 过滤非md文件 - filesList.push({ - name, - filePath - }); - } - } - } - }); - return filesList; -} - -module.exports = readFileList; diff --git a/vdoing/node_utils/setFrontmatter.js b/vdoing/node_utils/setFrontmatter.js deleted file mode 100644 index ea5c8ca..0000000 --- a/vdoing/node_utils/setFrontmatter.js +++ /dev/null @@ -1,163 +0,0 @@ -const fs = require('fs'); // 文件模块 -const matter = require('gray-matter'); // FrontMatter解析器 https://github.com/jonschlinkert/gray-matter -const jsonToYaml = require('json2yaml') -const chalk = require('chalk') // 命令行打印美化 -// const arg = process.argv.splice(2)[0]; // 获取命令行传入的参数 -const readFileList = require('./modules/readFileList'); -const { type, repairDate, dateFormat } = require('./modules/fn'); -const log = console.log -const path = require('path'); -const os = require('os'); - -const PREFIX = '/pages/' - -/** - * 给.md文件设置frontmatter(标题、日期、永久链接等数据) - */ -function setFrontmatter(sourceDir, themeConfig) { - const { category: isCategory, tag: isTag, categoryText = '随笔', extendFrontmatter } = themeConfig - const files = readFileList(sourceDir) // 读取所有md文件数据 - // 扩展自定义生成frontmatter - const extendFrontmatterStr = extendFrontmatter ? - jsonToYaml.stringify(extendFrontmatter) - .replace(/\n\s{2}/g, "\n") - .replace(/"|---\n/g, "") - : ''; - - files.forEach(file => { - let dataStr = fs.readFileSync(file.filePath, 'utf8');// 读取每个md文件内容 - - // fileMatterObj => {content:'剔除frontmatter后的文件内容字符串', data:{}, ...} - const fileMatterObj = matter(dataStr, {}); - - if (Object.keys(fileMatterObj.data).length === 0) { // 未定义FrontMatter数据 - const stat = fs.statSync(file.filePath); - const dateStr = dateFormat( - getBirthtime(stat) - ); // 文件的创建时间 - const categories = getCategories( - file, - categoryText - ); - - let cateLabelStr = ''; - categories.forEach(item => { - cateLabelStr += os.EOL + ' - ' + item - }); - - let cateStr = ''; - if (!(isCategory === false)) { - cateStr = os.EOL + 'categories:' + cateLabelStr - }; - - // 注意下面这些反引号字符串的格式会映射到文件 - const tagsStr = isTag === false ? '' : ` -tags: - - `; - - const fmData = `--- -title: ${file.name} -date: ${dateStr} -permalink: ${getPermalink()}${file.filePath.indexOf('_posts') > -1 ? os.EOL + 'sidebar: auto' : ''}${cateStr}${tagsStr} -${extendFrontmatterStr}---`; - - fs.writeFileSync(file.filePath, `${fmData}${os.EOL}${fileMatterObj.content}`); // 写入 - log(chalk.blue('tip ') + chalk.green(`write frontmatter(写入frontmatter):${file.filePath} `)) - - } else { // 已有FrontMatter - let matterData = fileMatterObj.data; - let hasChange = false; - - // 已有FrontMatter,但是没有title、date、permalink、categories、tags数据的 - if (!matterData.hasOwnProperty('title')) { // 标题 - matterData.title = file.name; - hasChange = true; - } - - if (!matterData.hasOwnProperty('date')) { // 日期 - const stat = fs.statSync(file.filePath); - matterData.date = dateFormat(getBirthtime(stat)); - hasChange = true; - } - - if (!matterData.hasOwnProperty('permalink')) { // 永久链接 - matterData.permalink = getPermalink(); - hasChange = true; - } - - if (file.filePath.indexOf('_posts') > -1 && !matterData.hasOwnProperty('sidebar')) { // auto侧边栏,_posts文件夹特有 - matterData.sidebar = "auto"; - hasChange = true; - } - - if (!matterData.hasOwnProperty('pageComponent') && matterData.article !== false) { // 是文章页才添加分类和标签 - if (isCategory !== false && !matterData.hasOwnProperty('categories')) { // 分类 - matterData.categories = getCategories(file, categoryText) - hasChange = true; - } - if (isTag !== false && !matterData.hasOwnProperty('tags')) { // 标签 - matterData.tags = ['']; - hasChange = true; - } - } - - // 扩展自动生成frontmatter的字段 - if (type(extendFrontmatter) === 'object') { - Object.keys(extendFrontmatter).forEach(keyName => { - if (!matterData.hasOwnProperty(keyName)) { - matterData[keyName] = extendFrontmatter[keyName] - hasChange = true; - } - }) - } - - if (hasChange) { - if (matterData.date && type(matterData.date) === 'date') { - matterData.date = repairDate(matterData.date) // 修复时间格式 - } - const newData = jsonToYaml.stringify(matterData).replace(/\n\s{2}/g, "\n").replace(/"/g, "") + '---' + os.EOL + fileMatterObj.content; - fs.writeFileSync(file.filePath, newData); // 写入 - log(chalk.blue('tip ') + chalk.green(`write frontmatter(写入frontmatter):${file.filePath} `)) - } - - } - }) -} - -// 获取分类数据 -function getCategories(file, categoryText) { - let categories = [] - - if (file.filePath.indexOf('_posts') === -1) { - // 不在_posts文件夹 - let filePathArr = file.filePath.split(path.sep) // path.sep用于兼容不同系统下的路径斜杠 - filePathArr.pop() - - let ind = filePathArr.indexOf('docs') - if (ind !== -1) { - while (filePathArr[++ind] !== undefined) { - const item = filePathArr[ind] - const firstDotIndex = item.indexOf('.'); - categories.push(item.substring(firstDotIndex + 1) || '') // 获取分类 - // categories.push(filePathArr[ind].split('.').pop()) // 获取分类 - } - } - } else { - categories.push(categoryText) - } - return categories -} - -// 获取文件创建时间 -function getBirthtime(stat) { - // 在一些系统下无法获取birthtime属性的正确时间,使用atime代替 - return stat.birthtime.getFullYear() != 1970 ? stat.birthtime : stat.atime -} - -// 定义永久链接数据 -function getPermalink() { - return `${PREFIX + (Math.random() + Math.random()).toString(16).slice(2, 8)}/` -} - - -module.exports = setFrontmatter; diff --git a/vdoing/noopModule.js b/vdoing/noopModule.js deleted file mode 100644 index b1c6ea4..0000000 --- a/vdoing/noopModule.js +++ /dev/null @@ -1 +0,0 @@ -export default {} diff --git a/vdoing/package.json b/vdoing/package.json deleted file mode 100644 index ca28aae..0000000 --- a/vdoing/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "vuepress-theme-vdoing", - "version": "1.12.0", - "description": "Vdoing theme for VuePress. 一个基于VuePress的知识管理兼博客主题。", - "author": { - "name": "gaoyi(Evan) Xu" - }, - "homepage": "https://github.com/xugaoyi/vuepress-theme-vdoing#readme", - "bugs": { - "url": "https://github.com/xugaoyi/vuepress-theme-vdoing/issues" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xugaoyi/vuepress-theme-vdoing.git" - }, - "keywords": [ - "documentation", - "vue", - "vuepress", - "generator", - "theme", - "blog" - ], - "license": "MIT", - "main": "index.js", - "maintainers": [ - { - "name": "Evan xu", - "email": "894072666@qq.com" - } - ], - "dependencies": { - "@better-scroll/core": "^2.0.0-beta.6", - "@better-scroll/slide": "^2.0.0-beta.6", - "@vuepress/plugin-active-header-links": "^1.2.0", - "@vuepress/plugin-nprogress": "^1.2.0", - "@vuepress/plugin-search": "^1.2.0", - "chalk": "^4.0.0", - "docsearch.js": "^2.5.2", - "good-storage": "^1.1.1", - "js-yaml": "^3.13.1", - "json2yaml": "^1.1.0", - "lodash": "^4.17.15", - "stylus": "^0.54.5", - "stylus-loader": "^3.0.2", - "vuepress-plugin-container": "^2.0.2", - "vuepress-plugin-smooth-scroll": "^0.0.3" - }, - "devDependencies": { - "@vuepress/types": "^1.9.5" - } -} diff --git a/vdoing/styles/arrow.styl b/vdoing/styles/arrow.styl deleted file mode 100644 index 20bffc0..0000000 --- a/vdoing/styles/arrow.styl +++ /dev/null @@ -1,22 +0,0 @@ -@require './config' - -.arrow - display inline-block - width 0 - height 0 - &.up - border-left 4px solid transparent - border-right 4px solid transparent - border-bottom 6px solid $arrowBgColor - &.down - border-left 4px solid transparent - border-right 4px solid transparent - border-top 6px solid $arrowBgColor - &.right - border-top 4px solid transparent - border-bottom 4px solid transparent - border-left 6px solid $arrowBgColor - &.left - border-top 4px solid transparent - border-bottom 4px solid transparent - border-right 6px solid $arrowBgColor diff --git a/vdoing/styles/code-theme.styl b/vdoing/styles/code-theme.styl deleted file mode 100644 index 922a67c..0000000 --- a/vdoing/styles/code-theme.styl +++ /dev/null @@ -1,274 +0,0 @@ -// 适合浅色背景 //@import '~prismjs/themes/prism.css' -codeThemeLight() - code[class*="language-"], - pre[class*="language-"] { - color: black; - background: none; - text-shadow: 0 1px white; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; - font-size: 1em; - text-align: left; - white-space: pre; - word-spacing: normal; - word-break: normal; - word-wrap: normal; - line-height: 1.5; - - -moz-tab-size: 4; - -o-tab-size: 4; - tab-size: 4; - - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; - hyphens: none; - } - - pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, - code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { - text-shadow: none; - background: #b3d4fc; - } - - pre[class*="language-"]::selection, pre[class*="language-"] ::selection, - code[class*="language-"]::selection, code[class*="language-"] ::selection { - text-shadow: none; - background: #b3d4fc; - } - - @media print { - code[class*="language-"], - pre[class*="language-"] { - text-shadow: none; - } - } - - /* Code blocks */ - pre[class*="language-"] { - padding: 1em; - margin: .5em 0; - overflow: auto; - } - - :not(pre) > code[class*="language-"], - pre[class*="language-"] { - background: #f5f2f0; - } - - /* Inline code */ - :not(pre) > code[class*="language-"] { - padding: .1em; - border-radius: .3em; - white-space: normal; - } - - .token.comment, - .token.prolog, - .token.doctype, - .token.cdata { - color: slategray; - } - - .token.punctuation { - color: #999; - } - - .namespace { - opacity: .7; - } - - .token.property, - .token.tag, - .token.boolean, - .token.number, - .token.constant, - .token.symbol, - .token.deleted { - color: #905; - } - - .token.selector, - .token.attr-name, - .token.string, - .token.char, - .token.builtin, - .token.inserted { - color: #690; - } - - .token.operator, - .token.entity, - .token.url, - .language-css .token.string, - .style .token.string { - color: #9a6e3a; - background: hsla(0, 0%, 100%, .5); - } - - .token.atrule, - .token.attr-value, - .token.keyword { - color: #07a; - } - - .token.function, - .token.class-name { - color: #DD4A68; - } - - .token.regex, - .token.important, - .token.variable { - color: #e90; - } - - .token.important, - .token.bold { - font-weight: bold; - } - .token.italic { - font-style: italic; - } - - .token.entity { - cursor: help; - } - - // 行高亮颜色 - div[class*="language-"] - .highlight-lines - .highlighted - background-color rgba(200, 200, 200, 40%) - &.line-numbers-mode - .highlight-lines .highlighted - &:before - background-color rgba(200, 200, 200, 40%) - - -// 适合深色背景 // @import '~prismjs/themes/prism-tomorrow.css' -codeThemeDark() - code[class*="language-"], - pre[class*="language-"] { - color: #ccc; - background: none; - text-shadow: none; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; - font-size: 1em; - text-align: left; - white-space: pre; - word-spacing: normal; - word-break: normal; - word-wrap: normal; - line-height: 1.5; - - -moz-tab-size: 4; - -o-tab-size: 4; - tab-size: 4; - - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; - hyphens: none; - - } - - /* Code blocks */ - pre[class*="language-"] { - padding: 1em; - margin: .5em 0; - overflow: auto; - } - - :not(pre) > code[class*="language-"], - pre[class*="language-"] { - background: #2d2d2d; - } - - /* Inline code */ - :not(pre) > code[class*="language-"] { - padding: .1em; - border-radius: .3em; - white-space: normal; - } - - .token.comment, - .token.block-comment, - .token.prolog, - .token.doctype, - .token.cdata { - color: #999; - } - - .token.punctuation { - color: #ccc; - } - - .token.tag, - .token.attr-name, - .token.namespace, - .token.deleted { - color: #e2777a; - } - - .token.function-name { - color: #6196cc; - } - - .token.boolean, - .token.number, - .token.function { - color: #f08d49; - } - - .token.property, - .token.class-name, - .token.constant, - .token.symbol { - color: #f8c555; - } - - .token.selector, - .token.important, - .token.atrule, - .token.keyword, - .token.builtin { - color: #cc99cd; - } - - .token.string, - .token.char, - .token.attr-value, - .token.regex, - .token.variable { - color: #7ec699; - } - - .token.operator, - .token.entity, - .token.url { - color: #67cdcc; - } - - .token.operator, - .token.entity, - .token.url, - .language-css .token.string, - .style .token.string { - background: none; - } - - .token.important, - .token.bold { - font-weight: bold; - } - .token.italic { - font-style: italic; - } - - .token.entity { - cursor: help; - } - - .token.inserted { - color: green; - } diff --git a/vdoing/styles/code.styl b/vdoing/styles/code.styl deleted file mode 100644 index 36206af..0000000 --- a/vdoing/styles/code.styl +++ /dev/null @@ -1,142 +0,0 @@ -body {$contentClass} - code - color var(--textLightenColor) - padding 0.25rem 0.5rem - margin 0 - font-size 0.9em - // background-color rgba(27,31,35,0.05) - background-color rgba(100,100,100,0.08) - border-radius 3px - .token - &.deleted - color #EC5975 - &.inserted - color $accentColor - -body {$contentClass} - pre, pre[class*="language-"] - line-height 1.4 - padding 1.25rem 1.5rem - margin 0.85rem 0 - background-color $codeBgColor - border-radius 6px - overflow auto - code - // color #fff - color var(--codeColor) - padding 0 - background-color transparent - border-radius 0 - -div[class*="language-"] - position relative - // background-color $codeBgColor - background-color var(--codeBg) - border-radius 6px - .highlight-lines - user-select none - padding-top 1.3rem - position absolute - top 0 - left 0 - width 100% - line-height 1.4 - .highlighted - background-color rgba(0, 0, 0, 30%) - pre, pre[class*="language-"] - background transparent - position relative !important - z-index 1 - &::before - position absolute - z-index 3 - top 0.8em - right 1em - font-size 0.8rem - color rgba(150,150,150,.7) - // color rgba(255, 255, 255, 0.4) - &:not(.line-numbers-mode) - .line-numbers-wrapper - display none - &.line-numbers-mode - .highlight-lines .highlighted - position relative - &:before - content ' ' - position absolute - z-index 3 - left 0 - top 0 - display block - width $lineNumbersWrapperWidth - height 100% - background-color rgba(0, 0, 0, 30%) - pre - padding-left $lineNumbersWrapperWidth + 1 rem - vertical-align middle - .line-numbers-wrapper - position absolute - top 0 - width $lineNumbersWrapperWidth - text-align center - // color rgba(255, 255, 255, 0.3) - color rgba(127, 127, 127, .5) - padding 1.25rem 0 - line-height 1.4 - br - user-select none - .line-number - position relative - z-index 4 - user-select none - font-size 0.85em - &::after - content '' - position absolute - z-index 2 - top 0 - left 0 - width $lineNumbersWrapperWidth - height 100% - border-radius 6px 0 0 6px - // border-right 1px solid rgba(0, 0, 0, 66%) - // background-color $codeBgColor - border-right 1px solid var(--borderColor) - background-color var(--codeBg) - - -for lang in $codeLang - div{'[class~="language-' + lang + '"]'} - &:before - content ('' + lang) - -div[class~="language-javascript"] - &:before - content "js" - -div[class~="language-typescript"] - &:before - content "ts" - -div[class~="language-markup"] - &:before - content "html" - -div[class~="language-markdown"] - &:before - content "md" - -div[class~="language-json"]:before - content "json" - -div[class~="language-ruby"]:before - content "rb" - -div[class~="language-python"]:before - content "py" - -div[class~="language-bash"]:before - content "sh" - -div[class~="language-php"]:before - content "php" diff --git a/vdoing/styles/config.styl b/vdoing/styles/config.styl deleted file mode 100644 index fa973ff..0000000 --- a/vdoing/styles/config.styl +++ /dev/null @@ -1 +0,0 @@ -$contentClass = '.theme-vdoing-content' diff --git a/vdoing/styles/custom-blocks.styl b/vdoing/styles/custom-blocks.styl deleted file mode 100644 index e212779..0000000 --- a/vdoing/styles/custom-blocks.styl +++ /dev/null @@ -1,87 +0,0 @@ -.custom-block - .custom-block-title - font-weight 600 - margin-bottom .2rem - p - margin 0 - &.tip, &.warning, &.danger, &.note - padding .5rem 1.5rem - border-left-width .5rem - border-left-style solid - margin 1rem 0 - &.tip - background-color #f3f5f7 - border-color #42b983 - color darken(#42b983, 50%) - &.warning - background-color #FFF7D0 - border-color darken(#ffe564, 35%) - color darken(#ffe564, 70%) - .custom-block-title - color darken(#ffe564, 50%) - a - color var(--textColor) - &.danger - background-color #ffe6e6 - border-color darken(red, 20%) - color darken(red, 70%) - .custom-block-title - color darken(red, 40%) - a - color var(--textColor) - &.note - background-color #E8F5FA - border-color #157BAE - color darken(#157BAE, 40%) - &.right - color var(--textColor) - font-size 0.9rem - text-align right - &.theorem - margin 1rem 0 - padding .8rem 1.5rem - border-radius 2px - background-color var(--customBlockBg) - .title - font-weight bold - margin .5rem 0 - &.details - display block - position relative - border-radius 2px - margin 1em 0 - padding 1.6em - background-color var(--customBlockBg) - p - margin .8rem 0 - h4 - margin-top 0 - figure, p - &:last-child - margin-bottom 0 - padding-bottom 0 - summary - outline none - cursor pointer - &:hover - color $accentColor - -// 深色模式适配 -.theme-mode-dark - .custom-block - &.warning - background-color rgba(255, 247, 208, .2) - color darken(#ffe564, 35%) - .custom-block-title - color darken(#ffe564, 15%) - &.tip - background-color rgba(243, 245, 247, .2) - color darken(#42b983, 0%) - &.danger - background-color rgba(255, 230, 230, .4) - color darken(red, 50%) - a - color $accentColor - &.note - background-color rgba(243, 245, 247, .2) - color darken(#157BAE, 0%) diff --git a/vdoing/styles/index.styl b/vdoing/styles/index.styl deleted file mode 100644 index f27a48e..0000000 --- a/vdoing/styles/index.styl +++ /dev/null @@ -1,318 +0,0 @@ -// 引入字体图标 -@import '//at.alicdn.com/t/font_1678482_4tbhmh589x.css' - -@require './config' -@require './code' -@require './custom-blocks' -@require './arrow' -@require './wrapper' -@require './toc' -@require './markdown-container' - - -html, body - padding 0 - margin 0 - -body - font-family -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif - -webkit-font-smoothing antialiased - -moz-osx-font-smoothing grayscale - -webkit-tap-highlight-color transparent - font-size 16px - color $textColor - background var(--bodyBg) - -// 去掉黄色边框 -a,input,button - outline: none; -webkit-tap-highlight-color: rgba(255, 255, 255, 0); -webkit-focus-ring-color: rgba(0, 0, 0, 0); -// 滚动条样式 -@media (min-width: $MQMobile) - ::-webkit-scrollbar - width:6px; - height:5px; - ::-webkit-scrollbar-track-piece - background-color:rgba(0,0,0,.15) - -webkit-border-radius:3px - ::-webkit-scrollbar-thumb:vertical - height:5px; - background-color:rgba(0,0,0,.28) - -webkit-border-radius:3px - ::-webkit-scrollbar-thumb:horizontal - width:5px; - background-color:rgba(0,0,0,.28) - -webkit-border-radius:3px - - -.card-box // 卡片 - border-radius 5px - background var(--mainBg) - box-shadow 0px 0px 4px 0 rgba(0,0,0,.1) - transition box-shadow .5s - &:hover - box-shadow 0 1px 15px 0 rgba(0,0,0,.1) - -.theme-style-line - @media (max-width: 719px) - margin-left: -1px; - margin-right: -1px; - .card-box - box-shadow 0 0 - border: 1px solid var(--borderColor) - -.blur // 模糊滤镜 - backdrop-filter saturate(200%) blur(20px) - -.custom-page // 自定义页面 - min-height calc(100vh - 3.6rem) - padding-top $navbarHeight - padding-bottom .9rem - .theme-vdoing-wrapper - margin 0 auto - -// 默认的搜索框样式重置 -body .search-box - input - background-color transparent - color var(--textColor) - border 1px solid var(--borderColor, #ccc) - @media (max-width: $MQNarrow) - border-color transparent - - - -.page - transition padding .2s ease - padding-left .8rem - -.navbar - position fixed - z-index 20 - top 0 - left 0 - right 0 - height $navbarHeight - background-color var(--blurBg) - box-sizing border-box - box-shadow 0 2px 5px rgba(0,0,0,.06) - -.sidebar-mask - position fixed - z-index 12 - top 0 - left 0 - width 100vw - height 100vh - display none - -.sidebar-hover-trigger - display none - position: fixed - z-index 12 - top ($navbarHeight + 4.5rem) - left 0 - bottom 0 - width 24px - -.sidebar - font-size 16px - background-color var(--sidebarBg) - width $sidebarWidth - position fixed - z-index 13 - margin 0 - top $navbarHeight - left 0 - bottom 0 - box-sizing border-box - border-right 1px solid var(--borderColor) - overflow-y auto - transform translateX(-100%) - transition transform .2s - @media (max-width: $MQMobile) - background-color var(--mainBg) - - -{$contentClass}:not(.custom) - word-wrap break-word - @extend $wrapper - > *:first-child - // margin-top $navbarHeight // 内容第一个元素的top距离 - - a:hover - text-decoration underline - - p.demo - padding 1rem 1.5rem - border 1px solid #ddd - border-radius 4px - - img - max-width 100% - -{$contentClass}.custom - padding 0 - margin 0 - - img - max-width 100% - -a - font-weight 500 - color $accentColor - text-decoration none - -p a code - font-weight 400 - color $accentColor - -kbd - background #eee - border solid 0.15rem #ddd - border-bottom solid 0.25rem #ddd - border-radius 0.15rem - padding 0 0.15em - -blockquote - font-size 1rem - opacity .75 - border-left .2rem solid rgba(100,100,100,.3) - margin 1rem 0 - padding .25rem 0 .25rem 1rem - - & > p - margin 0 - -ul, ol - padding-left 1.2em - -strong - font-weight 600 - -h1, h2, h3, h4, h5, h6 - font-weight 600 - line-height 1.25 - - {$contentClass}:not(.custom) > & - margin-top (0.5rem - $navbarHeight) - padding-top ($navbarHeight + 1rem) - margin-bottom 0 - - &:first-child - // margin-top -1.5rem - margin-bottom 1rem - - + p, + pre, + .custom-block - margin-top 2rem - - &:focus .header-anchor, - &:hover .header-anchor - opacity: 1 - - -// 没有h1标签时 -p,pre,.custom-block - {$contentClass}:not(.custom) > & - &:first-child - margin-top 2rem - - -h1 - font-size 1.9rem - {$contentClass}:not(.custom) > & // 页面内容的首个h1标签隐藏 - &:first-child - display none - -h2 - font-size 1.5rem - padding-bottom .3rem - border-bottom 1px solid var(--borderColor) - -h3 - font-size 1.35rem - -.page - h4 - font-size 1.25rem - h5 - font-size 1.15rem - h6 - font-size 1.05rem - -a.header-anchor - font-size 0.85em - float left - margin-left -0.87em - padding-right 0.23em - margin-top 0.125em - opacity 0 - - &:focus, - &:hover - text-decoration none - -code, kbd, .line-number - font-family source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace - -p, ul, ol - line-height 1.7 - -hr - border 0 - border-top 1px solid var(--borderColor) - -table - border-collapse collapse - margin 1rem 0 - overflow-x: auto - width 100% - display inline-table - @media (max-width: $MQMobile) - display block -tr - border-top 1px solid var(--borderColor) - - &:nth-child(2n) - background-color rgba(150,150,150,0.1) - -th, td - border 1px solid var(--borderColor) - padding .6em 1em - @media (max-width: $MQMobile) - padding .3em .5em - a - word-break break-all - -.theme-container - // background var(--mainBg) - color var(--textColor) - min-height 100vh - &.sidebar-open - .sidebar-mask - display: block - - &.no-navbar - {$contentClass}:not(.custom) > h1, h2, h3, h4, h5, h6 - margin-top 1.5rem - padding-top 0 - - .sidebar - top 0 - - -@media (min-width: ($MQMobile + 1px)) - .theme-container.no-sidebar - .sidebar - display none - - .page - padding-left 0 - -@require 'mobile.styl' - -// 打印时的样式 -@media print - .navbar,.sidebar,.buttons - display: none - .page - padding-top: 0 !important diff --git a/vdoing/styles/markdown-container.styl b/vdoing/styles/markdown-container.styl deleted file mode 100644 index 9f9e0bc..0000000 --- a/vdoing/styles/markdown-container.styl +++ /dev/null @@ -1,211 +0,0 @@ -// markdown容器样式 - -// 居中容器 -.center-container - text-align: center - -h1, h2, h3, h4, h5, h6 - .center-container > & - margin-top (0.5rem - $navbarHeight) - padding-top ($navbarHeight + 1rem) - margin-bottom 0 - a.header-anchor - float none - padding-right: 0 - margin-left: -.9rem - - -// 普通卡片列表 -.cardListContainer - margin .7rem 0 - &>:not(.card-list) - display none - .card-list - margin -0.35rem - display: flex; - flex-wrap: wrap; - align-items: flex-start; - .card-item - width calc(100%/3 - .7rem) - margin .35rem - background var(--bodyBg) - border-radius 3px - color var(--textColor) - display flex - box-shadow 1px 1px 2px 0 rgba(0,0,0,.06) - transition all .4s - &:hover - text-decoration none - box-shadow: 0 10px 20px -10px var(--randomColor, rgba(0,0,0,0.15)); - transform: translateY(-3px) scale(1.01, 1.01) - img - // transform rotate(8deg) scale(1.1, 1.1) - box-shadow 3px 2px 7px rgba(0, 0, 0, 0.15) - div p - text-shadow 3px 2px 5px rgba(0, 0, 0, 0.15) - img - width 60px - height 60px - border-radius 50% - border 2px solid #fff - margin 1rem - margin-right 0 - box-shadow 3px 2px 5px rgba(0, 0, 0, 0.08) - transition all .4s - div - flex 1 - display inline-block - float right - padding 1rem 0 - p - margin 0 - padding 0 1rem - transition text-shadow .4s - text-align center - .name - margin .2rem 0 .3rem 0 - .desc - font-size .8rem - line-height 1.1rem - opacity .8 - margin-bottom .2rem - .card-item.row-1 - width calc(100% - .7rem) - img - margin-left 2rem - .card-item.row-2 - width calc(100%/2 - .7rem) - img - margin-left 1.5rem - .card-item.row-3 - width calc(100%/3 - .7rem) - .card-item.row-4 - width calc(100%/4 - .7rem) - -// 图文卡片列表 -.cardImgListContainer - margin 1rem 0 - &>:not(.card-list) - display none - .card-list - margin -0.5rem - display: flex; - flex-wrap: wrap; - align-items: flex-start; - .card-item - width calc(100%/3 - 1rem) - margin .5rem - background var(--mainBg) - border 1px solid rgba(0,0,0,0.1) - box-sizing: border-box - border-radius 3px - overflow hidden - color var(--textColor) - box-shadow 2px 2px 10px rgba(0,0,0,.04) - display flex - flex-direction: column; - justify-content: flex-start; - align-items: stretch; - align-content: stretch; - transition: all .4s - &:hover - box-shadow 1px 1px 20px rgba(0,0,0,.1) - transform: translateY(-3px) - .box-img - overflow hidden - position relative - background #eee - img - display block - width 100% - height 100% - transition: all .3s - // &:hover - // img - // transform: scale(1.1, 1.1) - // opacity .75 - a - color var(--textColor) - transition: color .3s - &:hover - // color $accentColor - text-decoration none - .box-info - padding: .8rem 1rem - p - margin 0 - .desc - margin-top: .3rem - opacity .8 - font-size: .9rem - line-height: 1.1rem - overflow: hidden; - white-space: normal; - text-overflow: ellipsis; - display: -webkit-box; - -webkit-box-orient: vertical; - .box-footer - overflow hidden - padding: .8rem 1rem - border-top: 1px solid rgba(0,0,0,0.1) - img - width 1.8rem - height 1.8rem - border-radius 50% - float left - span - line-height 1.8rem - float left - margin-left: .6rem - font-size: .8rem - .card-item.row-1 - width calc(100% - 1rem) - .card-item.row-2 - width calc(100%/2 - 1rem) - .card-item.row-3 - width calc(100%/3 - 1rem) - .card-item.row-4 - width calc(100%/4 - 1rem) - -.theme-mode-dark - .cardImgListContainer - .card-list - .card-item - border-color: var(--borderColor) - .box-footer - border-color: var(--borderColor) - -// 卡片列表的响应 -@media (max-width: 900px) - .cardListContainer - .card-list - .card-item.row-4 - width calc(100%/3 - .7rem) - .cardImgListContainer - .card-list - .card-item.row-4 - width calc(100%/3 - 1rem) - -@media (max-width: 720px) - .cardListContainer - .card-list - .card-item.row-3, .card-item.row-4 - width calc(100%/2 - .7rem) - img - margin-left 1.5rem - .cardImgListContainer - .card-list - .card-item.row-3, .card-item.row-4 - width calc(100%/2 - 1rem) - -@media (max-width: 500px) - .cardListContainer - .card-list - .card-item.row-1, .card-item.row-2, .card-item.row-3, .card-item.row-4 - width calc(100% - .7rem) - img - margin-left 1.5rem - .cardImgListContainer - .card-list - .card-item.row-1, .card-item.row-2, .card-item.row-3, .card-item.row-4 - width calc(100% - 1rem) diff --git a/vdoing/styles/mobile.styl b/vdoing/styles/mobile.styl deleted file mode 100644 index 030405d..0000000 --- a/vdoing/styles/mobile.styl +++ /dev/null @@ -1,101 +0,0 @@ -@require './config' - -$mobileSidebarWidth = $sidebarWidth * 0.9 - -// narrow desktop / iPad -@media (max-width: $MQNarrow) - .sidebar - font-size 15px - -@media (max-width: $MQMobile) - .sidebar - width $sidebarWidth * 0.95 - -@media (min-width: ($MQMobile + 1px)) and (max-width: $MQNarrow) - .sidebar - width $mobileSidebarWidth - .theme-container - &.sidebar-open - .page - padding-left ($mobileSidebarWidth + .8rem)!important - -// wide mobile -@media (max-width: $MQMobile) - .sidebar - top 0 - height 100vh - padding-top $navbarHeight - transform translateX(-100%) - transition transform .2s ease - .page - padding-left 0 - .theme-container - &.sidebar-open - .sidebar - transform translateX(0) - .sidebar-mask // 蒙版在小屏中才能显示 - display block - &.no-navbar - .sidebar - padding-top: 0 - -// narrow mobile -@media (max-width: $MQMobileNarrow) - h1 - font-size 1.9rem - {$contentClass} - div[class*="language-"] - margin 0.85rem -1.5rem - border-radius 0 - -// 侧边栏显示隐藏的适配 -@media (min-width: ($MQMobile + 1px)) // 720px - .theme-container - .sidebar-hover-trigger - display: block - .sidebar-hover-trigger:hover ~ .sidebar - transform translateX(0) - z-index: 100 - - &:not(.sidebar-open) - .sidebar-hover-trigger ~ .sidebar:hover - transform translateX(0) - z-index: 100 - - &.sidebar-open - .sidebar-mask - display: none - .sidebar - transform translateX(0) - .sidebar-button - left $sidebarWidth - .page - padding-left ($sidebarWidth + .8rem) - padding-right .8rem - .sidebar-hover-trigger - display: none - - &.have-rightmenu - .page - padding-right ($rightMenuWidth + 20rem) - &.no-sidebar - .page - padding-left 0!important - .sidebar-hover-trigger - display: none - - &.hide-navbar - .sidebar-hover-trigger - top 4.5rem - .sidebar - top 0 - - @media (max-width: $MQNarrow) - .theme-container - &.sidebar-open:not(.on-sidebar) - .sidebar-button - $mobileSidebarWidth = $sidebarWidth * 0.7 - left $mobileSidebarWidth - .theme-container.no-sidebar - .sidebar-button - display none diff --git a/vdoing/styles/palette.styl b/vdoing/styles/palette.styl deleted file mode 100644 index e66eb26..0000000 --- a/vdoing/styles/palette.styl +++ /dev/null @@ -1,96 +0,0 @@ -// 主题调色板 - -// 原主题预设变量 -// 颜色 -// $accentColor = #3eaf7c -// $textColor = #2c3e50 -// $borderColor = #eaecef -// $codeBgColor = #282c34 -// $arrowBgColor = #ccc -// $badgeTipColor = #42b983 -// $badgeWarningColor = darken(#ffe564, 35%) -// $badgeErrorColor = #DA5961 -// 布局 -// $navbarHeight = 3.6rem -// $sidebarWidth = 20rem -// $contentWidth = 740px -// $homePageWidth = 960px -// 代码块 -// $lineNumbersWrapperWidth = 3.5rem - - -@require './code-theme' - -//***vdoing主题-变量***// - -// 颜色 - -$bannerTextColor = #fff // 首页banner区(博客标题)文本颜色 -$accentColor = #11A8CD -$activeColor = #ff5722 -$arrowBgColor = #ccc -// 放弃使用 -// $badgeTipColor = #42b983 -// $badgeWarningColor = darken(#ffe564, 35%) -// $badgeErrorColor = #DA5961 - -// 布局 -$navbarHeight = 3.6rem -$sidebarWidth = 18rem -$contentWidth = 860px -$homePageWidth = 1100px -$rightMenuWidth = 230px // 右侧菜单 - -// 代码块 -$lineNumbersWrapperWidth = 2.5rem - -// 浅色模式 -.theme-mode-light - --bodyBg: #f4f4f4 - --mainBg: rgba(255,255,255,1) - --sidebarBg: rgba(255,255,255,.8) - --blurBg: rgba(255,255,255,.9) - --customBlockBg: #f1f1f1 - --textColor: #00323c - --textLightenColor: #0085AD - --borderColor: rgba(0,0,0,.12) - --codeBg: #f6f6f6 - --codeColor: #525252 - codeThemeLight() - -// 深色模式 -.theme-mode-dark - --bodyBg: rgb(39,39,43) - --mainBg: rgba(30,30,34,1) - --sidebarBg: rgba(30,30,34,.8) - --blurBg: rgba(30,30,34,.8) - --customBlockBg: rgb(39,39,43) - --textColor: rgb(155,155,170) - --textLightenColor: #0085AD - // --borderColor: #2C2C3A - --borderColor: #30363d - --codeBg: #252526 - --codeColor: #fff - codeThemeDark() - -// 阅读模式 -.theme-mode-read - --bodyBg: rgb(236,236,204) - --mainBg: rgba(245,245,213,1) - --sidebarBg: rgba(245,245,213,.8) - --blurBg: rgba(245,245,213,.9) - --customBlockBg: rgb(236,236,204) - --textColor: #704214 - --textLightenColor: #996633 - --borderColor: rgba(0,0,0,.15) - --codeBg: #282c34 - --codeColor: #fff - codeThemeDark() - -// 背景色整体一致 -.theme-style-line.theme-mode-light - --bodyBg: rgba(255,255,255,1) -.theme-style-line.theme-mode-dark - --bodyBg: rgba(30,30,34,1) -.theme-style-line.theme-mode-read - --bodyBg: rgba(245,245,213,1) diff --git a/vdoing/styles/toc.styl b/vdoing/styles/toc.styl deleted file mode 100644 index d3e7106..0000000 --- a/vdoing/styles/toc.styl +++ /dev/null @@ -1,3 +0,0 @@ -.table-of-contents - .badge - vertical-align middle diff --git a/vdoing/styles/wrapper.styl b/vdoing/styles/wrapper.styl deleted file mode 100644 index eacda78..0000000 --- a/vdoing/styles/wrapper.styl +++ /dev/null @@ -1,17 +0,0 @@ -$vdoing-wrapper - max-width $contentWidth - margin 0 auto - padding 1rem 2.5rem 2rem 2.5rem - &:not(.footer) - background var(--mainBg) - box-shadow 0 1px 2px 0 rgba(0,0,0,.1) - // box-shadow 0 0 3px 0 rgba(0,0,0,.1) - margin-bottom 1rem - @media (min-width $contentWidth + 80) - border-radius 2px - @media (max-width: $MQNarrow) - padding 1rem 2rem - @media (max-width: $MQMobileNarrow) - padding 1rem 1.5rem -$wrapper - max-width $contentWidth diff --git a/vdoing/templates/dev.html b/vdoing/templates/dev.html deleted file mode 100644 index 2c53351..0000000 --- a/vdoing/templates/dev.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - -
- - \ No newline at end of file diff --git a/vdoing/templates/ssr.html b/vdoing/templates/ssr.html deleted file mode 100644 index db2fb63..0000000 --- a/vdoing/templates/ssr.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - {{ title }} - - {{{ userHeadTags }}} - {{{ pageMeta }}} - {{{ canonicalLink }}} - {{{ renderResourceHints() }}} - {{{ renderStyles() }}} - - - - {{{ renderScripts() }}} - - diff --git a/vdoing/types/index.ts b/vdoing/types/index.ts deleted file mode 100644 index 6f0791e..0000000 --- a/vdoing/types/index.ts +++ /dev/null @@ -1,175 +0,0 @@ -import { DefaultThemeConfig } from '@vuepress/types' - -type NoSidebar4DefaultThemeConfig = Omit // 忽略sidebar属性 - -/** - * Vdoing主题配置类型 - * @see https://doc.xugaoyi.com/ - */ -export interface VdoingThemeConfig extends NoSidebar4DefaultThemeConfig { - /** - * 是否打开分类功能. Enable classification - * @default true - */ - category?: boolean; - - /** - * 是否打开标签功能. Enable tag - * @default true - */ - tag?: boolean; - - /** - * 是否打开归档功能. Enable archive - * @default true - */ - archive?: boolean; - - /** - * 碎片化文章(_posts文件夹的文章)预设生成的分类值 - * @default '随笔' - */ - categoryText?: string; - - /** - * 页面风格 - * @default 'card' - */ - pageStyle?: 'card' | 'line'; - - /** - * body背景大图链接。单张图片 string | 多张图片 string[], 多张图片时每隔15秒换一张。 - * @default '' - */ - bodyBgImg?: string | string[]; - - /** - * body背景图透明度,选值 0.1 ~ 1.0 - * @default 0.5 - */ - bodyBgImgOpacity?: 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1; - - - /** - * body当多张背景图时,设置切换时间,默认15s - * @default 15 - */ - bodyBgImgInterval?: number; - - /** - * 是否显示文章标题前的图标 - * @default true - */ - titleBadge?: boolean; - - /** - * 文章标题前图标的地址 - * @default <内置图标> - */ - titleBadgeIcons?: string[]; - - /** - * 文章内容块的背景风格. 1 方格 | 2 横线 | 3 竖线 | 4 左斜线 | 5 右斜线 | 6 点状 - * @default - */ - contentBgStyle?: 1 | 2 | 3 | 4 | 5 | 6; - - /** - * 最近更新栏. showToArticle 是否显示到文章页底部,默认true。 moreArticle “更多文章”跳转的页面,默认'/archives' - * @default {showToArticle: true, moreArticle: '/archives'} - */ - updateBar?: { - showToArticle: boolean, - moreArticle?: '/archives' | string - }; - - /** - * 宽屏时是否显示右侧文章大纲栏 (屏宽小于1300px下无论如何都不显示) - * @default true - */ - rightMenuBar?: boolean; - - /** - * 初始状态是否打开左侧边栏 (注:这里只是决定收起还是展开侧边栏) - * @default true - */ - sidebarOpen?: boolean; - - /** - * 是否显示快捷翻页按钮 - * @default true - */ - pageButton?: boolean; - - /** - * 侧边栏配置 - */ - sidebar?: - | 'structuring' - | { mode: 'structuring', collapsable: Boolean } - | DefaultThemeConfig['sidebar'] - - /** - * 文章默认的作者信息 - */ - author?: string | { name: string, link?: string } - - /** - * 博主信息 (显示在首页侧边栏) - */ - blogger?: { - avatar: string, - name: string, - slogan?: string, - } - - /** - * 社交图标 (显示于博主信息栏和页脚栏) - * @内置图标-see:https://doc.xugaoyi.com/pages/a20ce8/#social - */ - social?: { - iconfontCssFile?: string, - icons: { - iconClass: string, - title: string, - link: string, - }[] - } - - /** - * 页脚信息 - */ - footer?: { - createYear: number, - copyrightInfo: string - } - - /** - * 扩展自动生成frontmatter。 - * 说明:当md文件的frontmatter不存在相应的字段时将自动添加。不会覆盖已有的数据。 - */ - extendFrontmatter?: { - [key: string]: any - } - - /** - * 自定义hmtl(广告)模块 - * @see: https://doc.xugaoyi.com/pages/a20ce8/#htmlmodules - */ - htmlModules?: { - homeSidebarB?: string, - sidebarT?: string, - sidebarB?: string, - pageT?: string, - pageB?: string, - pageTshowMode?: 'article' | 'custom', - pageBshowMode?: 'article' | 'custom', - windowLB?: string, - windowRB?: string, - } - - /** - * 兼容其他未列举配置项 - */ - [key: string]: any; -} diff --git a/vdoing/util/index.js b/vdoing/util/index.js deleted file mode 100644 index a623585..0000000 --- a/vdoing/util/index.js +++ /dev/null @@ -1,292 +0,0 @@ -export const hashRE = /#.*$/ -export const extRE = /\.(md|html)$/ -export const endingSlashRE = /\/$/ -export const outboundRE = /^[a-z]+:/i - -export function normalize(path) { - return decodeURI(path) - .replace(hashRE, '') - .replace(extRE, '') -} - -export function getHash(path) { - const match = path && path.match(hashRE) - if (match) { - return match[0] - } -} - -export function isExternal(path) { - return outboundRE.test(path) -} - -export function isMailto(path) { - return /^mailto:/.test(path) -} - -export function isTel(path) { - return /^tel:/.test(path) -} - -export function ensureExt(path) { - if (isExternal(path)) { - return path - } - if (!path) return '404' - const hashMatch = path.match(hashRE) - const hash = hashMatch ? hashMatch[0] : '' - const normalized = normalize(path) - - if (endingSlashRE.test(normalized)) { - return path - } - return normalized + '.html' + hash -} - -export function isActive(route, path) { - const routeHash = route.hash - const linkHash = getHash(path) - if (linkHash && routeHash !== linkHash) { - return false - } - const routePath = normalize(route.path) - const pagePath = normalize(path) - return routePath === pagePath -} - -export function resolvePage(pages, rawPath, base) { - if (isExternal(rawPath)) { - return { - type: 'external', - path: rawPath - } - } - if (base) { - rawPath = resolvePath(rawPath, base) - } - const path = normalize(rawPath) - for (let i = 0; i < pages.length; i++) { - if (normalize(pages[i].regularPath) === path) { - return Object.assign({}, pages[i], { - type: 'page', - path: ensureExt(pages[i].path) - }) - } - } - console.error(`[vuepress] No matching page found for sidebar item "${rawPath}"`) - return {} -} - -function resolvePath(relative, base, append) { - const firstChar = relative.charAt(0) - if (firstChar === '/') { - return relative - } - - if (firstChar === '?' || firstChar === '#') { - return base + relative - } - - const stack = base.split('/') - - // remove trailing segment if: - // - not appending - // - appending to trailing slash (last segment is empty) - if (!append || !stack[stack.length - 1]) { - stack.pop() - } - - // resolve relative path - const segments = relative.replace(/^\//, '').split('/') - for (let i = 0; i < segments.length; i++) { - const segment = segments[i] - if (segment === '..') { - stack.pop() - } else if (segment !== '.') { - stack.push(segment) - } - } - - // ensure leading slash - if (stack[0] !== '') { - stack.unshift('') - } - - return stack.join('/') -} - -/** - * @param { Page } page - * @param { string } regularPath - * @param { SiteData } site - * @param { string } localePath - * @returns { SidebarGroup } - */ -export function resolveSidebarItems(page, regularPath, site, localePath) { - const { pages, themeConfig } = site - - const localeConfig = localePath && themeConfig.locales - ? themeConfig.locales[localePath] || themeConfig - : themeConfig - - const pageSidebarConfig = page.frontmatter.sidebar || localeConfig.sidebar || themeConfig.sidebar - if (pageSidebarConfig === 'auto') { - return resolveHeaders(page) - } - - const sidebarConfig = localeConfig.sidebar || themeConfig.sidebar - if (!sidebarConfig) { - return [] - } else { - const { base, config } = resolveMatchingConfig(regularPath, sidebarConfig) - if (config === 'auto') { - return resolveHeaders(page) - } - return config - ? config.map(item => resolveItem(item, pages, base)) - : [] - } -} - -/** - * @param { Page } page - * @returns { SidebarGroup } - */ -function resolveHeaders(page) { - const headers = groupHeaders(page.headers || []) - return [{ - type: 'group', - collapsable: false, - title: page.title, - path: null, - children: headers.map(h => ({ - type: 'auto', - title: h.title, - basePath: page.path, - path: page.path + '#' + h.slug, - children: h.children || [] - })) - }] -} - -export function groupHeaders(headers) { - // group h3s under h2 - headers = headers.map(h => Object.assign({}, h)) - let lastH2 - headers.forEach(h => { - if (h.level === 2) { - lastH2 = h - } else if (lastH2) { - (lastH2.children || (lastH2.children = [])).push(h) - } - }) - return headers.filter(h => h.level === 2) -} - -export function resolveNavLinkItem(linkItem) { - return Object.assign(linkItem, { - type: linkItem.items && linkItem.items.length ? 'links' : 'link' - }) -} - -/** - * @param { Route } route - * @param { Array | Array | [link: string]: SidebarConfig } config - * @returns { base: string, config: SidebarConfig } - */ -export function resolveMatchingConfig(regularPath, config) { - if (Array.isArray(config)) { - return { - base: '/', - config: config - } - } - for (const base in config) { - if (ensureEndingSlash(regularPath).indexOf(encodeURI(base)) === 0) { - return { - base, - config: config[base] - } - } - } - return {} -} - -function ensureEndingSlash(path) { - return /(\.html|\/)$/.test(path) - ? path - : path + '/' -} - -function resolveItem(item, pages, base, groupDepth = 1) { - if (typeof item === 'string') { - return resolvePage(pages, item, base) - } else if (Array.isArray(item)) { - return Object.assign(resolvePage(pages, item[0], base), { - title: item[1] - }) - } else { - if (groupDepth > 3) { - console.error( - '[vuepress] detected a too deep nested sidebar group.' - ) - } - const children = item.children || [] - if (children.length === 0 && item.path) { - return Object.assign(resolvePage(pages, item.path, base), { - title: item.title - }) - } - return { - type: 'group', - path: item.path, - title: item.title, - sidebarDepth: item.sidebarDepth, - initialOpenGroupIndex: item.initialOpenGroupIndex, - children: children.map(child => resolveItem(child, pages, base, groupDepth + 1)), - collapsable: item.collapsable !== false - } - } -} - - -// 类型判断 -export function type(o) { - const s = Object.prototype.toString.call(o) - return s.match(/\[object (.*?)\]/)[1].toLowerCase() -} - -// 日期格式化(只获取年月日) -export function dateFormat(date) { - if (!(date instanceof Date)) { - date = new Date(date) - } - return `${date.getUTCFullYear()}-${zero(date.getUTCMonth() + 1)}-${zero(date.getUTCDate())}` -} - -// 小于10补0 -export function zero(d) { - return d.toString().padStart(2, '0') -} - -// 获取时间的时间戳 -export function getTimeNum(post) { - let dateStr = post.frontmatter.date || post.lastUpdated || new Date() - let date = new Date(dateStr) - if (date == "Invalid Date" && dateStr) { // 修复new Date()在Safari下出现Invalid Date的问题 - date = new Date(dateStr.replace(/-/g, '/')) - } - return date.getTime() -} - -// 比对时间 -export function compareDate(a, b) { - return getTimeNum(b) - getTimeNum(a) -} - -// 将特殊符号编码(应用于url) -export function encodeUrl(str) { - str = str + '' - str = str.replace(/ |((?=[\x21-\x7e]+)[^A-Za-z0-9])/g, '-') - return str -} diff --git a/vdoing/util/postData.js b/vdoing/util/postData.js deleted file mode 100644 index 91eba96..0000000 --- a/vdoing/util/postData.js +++ /dev/null @@ -1,108 +0,0 @@ -import { type, compareDate } from './index' - -/** - * 过滤非文章页 - * @param {Array} posts 所有文章数据 - */ -export function filterPosts (posts) { - posts = posts.filter(item => { - const { frontmatter: { pageComponent, article, home } } = item - return !(pageComponent || article === false || home === true) // 存在页面组件、article字段为false,以及首页 - }) - return posts -} - -/** - * 按置顶和时间排序 - * @param {Array} posts 过滤非文章页之后的文章数据 - */ -export function sortPosts (posts) { - posts.sort((prev, next) => { - const prevSticky = prev.frontmatter.sticky - const nextSticky = next.frontmatter.sticky - if (prevSticky && nextSticky) { - return prevSticky == nextSticky ? compareDate(prev, next) : (prevSticky - nextSticky) - } else if (prevSticky && !nextSticky) { - return -1 - } else if (!prevSticky && nextSticky) { - return 1 - } - return compareDate(prev, next) - }) - return posts -} - -/** - * 按时间排序 - * @param {Array} posts 过滤非文章页之后的文章数据 - */ -export function sortPostsByDate (posts) { - posts.sort((prev, next) => { - return compareDate(prev, next) - }) - return posts -} - -/** - * 按分类和标签分组 - * @param {Array} posts 按时间排序之后的文章数据 - */ -export function groupPosts (posts) { - const categoriesObj = {} - const tagsObj = {} - - for (let i = 0, postsL = posts.length; i < postsL; i++) { - const { frontmatter: { categories, tags } } = posts[i] - if (type(categories) === 'array') { - categories.forEach(item => { - if (item) { // 分类值是有效的 - if (!categoriesObj[item]) { - categoriesObj[item] = [] - } - categoriesObj[item].push(posts[i]) - } - }) - } - if (type(tags) === 'array') { - tags.forEach(item => { - if (item) { // 标签值是有效的 - if (!tagsObj[item]) { - tagsObj[item] = [] - } - tagsObj[item].push(posts[i]) - } - }) - } - } - return { - categories: categoriesObj, - tags: tagsObj - } -} - -/** - * 获取所有分类和标签 - * @param {Object} groupPosts 按分类和标签分组之后的文章数据 - */ -export function categoriesAndTags (groupPosts) { - const categoriesArr = [] - const tagsArr = [] - - for (let key in groupPosts.categories) { - categoriesArr.push({ - key, - length: groupPosts.categories[key].length - }) - } - - for (let key in groupPosts.tags) { - tagsArr.push({ - key, - length: groupPosts.tags[key].length - }) - } - return { - categories: categoriesArr, - tags: tagsArr - } -}