diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index a862fa7e..b7df33d0 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,8 +1,26 @@ import { defineConfig } from 'vitepress' +// 时间线 import timeline from 'vitepress-markdown-timeline' +// 任务列表 import taskLists from "markdown-it-task-lists" +// mathjax3公式支持 import mathjax3 from 'markdown-it-mathjax3' +// 页脚 import footnote_plugin from 'markdown-it-footnote' +// 双向链接 +import { BiDirectionalLinks } from '@nolebase/markdown-it-bi-directional-links' +// 行内链接预览 +import { InlineLinkPreviewElementTransform } from '@nolebase/vitepress-plugin-inline-link-preview/markdown-it' +// 基于git的页面历史 +import { + GitChangelog, + GitChangelogMarkdownSection, +} from '@nolebase/vitepress-plugin-git-changelog/vite' +// 页面属性 +import { + PageProperties, + PagePropertiesMarkdownSection +} from '@nolebase/vitepress-plugin-page-properties/vite' export default defineConfig({ lang: 'zh-CN', @@ -10,6 +28,7 @@ export default defineConfig({ title: 'karin', description: '基于 Kritor 进行开发的nodejs机器人框架', markdown: { + math: true, // 全局代码块行号显示 lineNumbers: true, image: { @@ -25,8 +44,36 @@ export default defineConfig({ md.use(mathjax3) // 脚注 md.use(footnote_plugin) + // 双向链接 + md.use(BiDirectionalLinks()) + // 行内链接预览 + md.use(InlineLinkPreviewElementTransform) }, }, + vite: { + plugins: [ + GitChangelog({ + // 要获取git日志的仓库 + repoURL: () => 'https://github.com/KarinJS/Karin', + }), + GitChangelogMarkdownSection({ + sections: { + // 禁用页面历史 + disableChangelog: false, + // 禁用贡献者 + disableContributors: false, + }, + }), + // 页面属性 + PageProperties(), + PagePropertiesMarkdownSection({ + excludes: [ + 'toc.md', + 'index.md', + ], + }), + ], + }, vue: { template: { compilerOptions: { diff --git a/docs/.vitepress/theme/components/Share.vue b/docs/.vitepress/theme/components/Share.vue new file mode 100644 index 00000000..8dd3b9ec --- /dev/null +++ b/docs/.vitepress/theme/components/Share.vue @@ -0,0 +1,118 @@ + + + \ No newline at end of file diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index bc00fa3e..2e3c2b74 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,16 +1,104 @@ -/* .vitepress\theme\index.ts */ import DefaultTheme from 'vitepress/theme' import mediumZoom from 'medium-zoom' -import { onMounted, watch, nextTick } from 'vue' +import { onMounted, watch, nextTick, h } from 'vue' import { useData, useRoute } from 'vitepress' import 'vitepress-markdown-timeline/dist/theme/index.css' import './style/index.css' +// 代码块添加折叠 +import codeblocksFold from 'vitepress-plugin-codeblocks-fold' +import 'vitepress-plugin-codeblocks-fold/style/index.css' +// 基于git的页面历史 +import { + NolebaseGitChangelogPlugin +} from '@nolebase/vitepress-plugin-git-changelog/client' +import '@nolebase/vitepress-plugin-git-changelog/client/style.css' +// 行内链接预览 +import { + NolebaseInlineLinkPreviewPlugin, +} from '@nolebase/vitepress-plugin-inline-link-preview/client' +import '@nolebase/vitepress-plugin-inline-link-preview/client/style.css' +// 顶级的阅读增强,页面右上角小书本 +import { + NolebaseEnhancedReadabilitiesMenu, + NolebaseEnhancedReadabilitiesScreenMenu, +} from '@nolebase/vitepress-plugin-enhanced-readabilities/client' +import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css' +// 闪烁高亮当前目标标题 +import { + NolebaseHighlightTargetedHeading, +} from '@nolebase/vitepress-plugin-highlight-targeted-heading/client' +// 快速复制当前页的url +import Share from './components/Share.vue' +// 页面属性 +import { + NolebasePagePropertiesPlugin, +} from '@nolebase/vitepress-plugin-page-properties/client' +import '@nolebase/vitepress-plugin-page-properties/client/style.css' export default { extends: DefaultTheme, + enhanceApp ({ app }) { + app.use(NolebaseGitChangelogPlugin) + app.use(NolebaseInlineLinkPreviewPlugin) + // app.use(NuAsciinemaPlayer) + app.use(NolebasePagePropertiesPlugin<{ + progress: number + }>(), { + properties: { + 'zh-CN': [ + { + key: 'wordCount', + type: 'dynamic', + title: '字数', + options: { + type: 'wordsCount', + }, + }, + { + key: 'readingTime', + type: 'dynamic', + title: '阅读时间', + options: { + type: 'readingTime', + dateFnsLocaleName: 'zhCN', + }, + }, + { + key: 'updatedAt', + type: 'datetime', + title: '更新时间', + formatAsFrom: true, + dateFnsLocaleName: 'zhCN', + }, + ], + }, + }) + }, + Layout: () => { + return h(DefaultTheme.Layout, null, { + + 'nav-bar-content-after': () => [ + // 为较宽的屏幕的导航栏添加阅读增强菜单 + h(NolebaseEnhancedReadabilitiesMenu), + // 快速复制当前页的url + h(Share), + ], + // 为较窄的屏幕(通常是小于 iPad Mini)添加阅读增强菜单 + 'nav-screen-content-after': () => h(NolebaseEnhancedReadabilitiesScreenMenu), + 'layout-top': () => [ + h(NolebaseHighlightTargetedHeading), + ], + }) + }, + /** 响应式图片缩放 */ setup () { const route = useRoute() + // 获取前言和路由 + const { frontmatter } = useData() + // 代码块添加折叠 + codeblocksFold({ route, frontmatter }, true, 400) + const initZoom = () => { // 响应式的图片放大缩小 // mediumZoom('[data-zoomable]', { background: 'var(--vp-c-bg)' }); // 默认 @@ -23,6 +111,5 @@ export default { () => route.path, () => nextTick(() => initZoom()) ) - const { frontmatter } = useData() }, } \ No newline at end of file diff --git a/docs/.vitepress/theme/style/index.css b/docs/.vitepress/theme/style/index.css index 42fab3e9..12197837 100644 --- a/docs/.vitepress/theme/style/index.css +++ b/docs/.vitepress/theme/style/index.css @@ -1,3 +1,4 @@ @import './var.css'; @import './vp-code-group.css'; -@import './mathjax3.css'; \ No newline at end of file +@import './mathjax3.css'; +@import './main.css' \ No newline at end of file diff --git a/docs/.vitepress/theme/style/main.css b/docs/.vitepress/theme/style/main.css new file mode 100644 index 00000000..2f47de88 --- /dev/null +++ b/docs/.vitepress/theme/style/main.css @@ -0,0 +1,3 @@ +.VPSocialLinks.VPNavBarSocialLinks.social-links { + margin-right: 0; +} \ No newline at end of file diff --git a/docs/.vitepress/theme/style/var.css b/docs/.vitepress/theme/style/var.css index abc5029d..df806a99 100644 --- a/docs/.vitepress/theme/style/var.css +++ b/docs/.vitepress/theme/style/var.css @@ -1,13 +1,9 @@ /* var.css */ /* */ :root { - /* 主题色,浅色模式,深紫色调 */ - /* 鼠标滑过高亮色,代码块高亮色,加粗高亮色 */ --vp-c-brand-1: #5224b6; - /* --vp-c-brand-1-2: #5224b6; */ --vp-c-brand-2: #352984; --vp-c-brand-3: #6d68c1; - /* 主页logo大图底色 设置右图像渐变 */ --vp-home-hero-image-background-image: linear-gradient(-45deg, #f6abe9 50%, #ebe0ba 50%); --vp-home-hero-image-filter: blur(150px); } diff --git a/docs/index.md b/docs/index.md index 76a92d06..8aa9f486 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,15 +5,16 @@ hero: name: Karin tagline: 基于 Kritor 标准进行开发的nodejs机器人框架 actions: - - theme: alt - text: onebots - link: https://docs.onebots.org/ - - theme: alt - text: 插件索引 - link: /plugins/index - theme: brand text: 快速上手 link: /start/start + - theme: alt + text: 插件索引 + link: /plugins/index + - theme: alt + text: onebots + link: https://docs.onebots.org/ + features: - title: 轻量级 diff --git a/package.json b/package.json index 169c84e1..e5c0940f 100644 --- a/package.json +++ b/package.json @@ -3,20 +3,28 @@ "author": "Lain", "version": "0.0.3", "type": "module", - "devDependencies": { - "vitepress": "^1.3.0" - }, "scripts": { "dev": "vitepress dev docs", "build": "vitepress build docs", "preview": "vitepress preview docs" }, "dependencies": { + "@nolebase/markdown-it-bi-directional-links": "^2.2.2", + "@nolebase/vitepress-plugin-enhanced-readabilities": "^2.2.2", + "@nolebase/vitepress-plugin-git-changelog": "^2.2.2", + "@nolebase/vitepress-plugin-highlight-targeted-heading": "^2.2.2", + "@nolebase/vitepress-plugin-inline-link-preview": "^2.2.2", + "@nolebase/vitepress-plugin-meta": "^2.2.2", + "@nolebase/vitepress-plugin-page-properties": "^2.2.2", + "@vueuse/core": "^10.11.0", "markdown-it-footnote": "^4.0.0", "markdown-it-mathjax3": "^4.3.2", "markdown-it-task-lists": "^2.1.1", "medium-zoom": "^1.1.0", + "vite": "^5.3.4", + "vitepress": "^1.3.1", "vitepress-markdown-timeline": "^1.2.1", + "vitepress-plugin-codeblocks-fold": "^1.2.28", "vue": "^3.4.33" } } \ No newline at end of file