From c0eea64b9967ff8ca041237547f85a4070babb34 Mon Sep 17 00:00:00 2001 From: Hyouka Date: Wed, 5 Jun 2024 19:24:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20n=C3=B3l=C3=ABbase=20integrations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 5 + .vitepress/config.ts | 52 +- .vitepress/locales/en/docs-feedback.ts | 2 +- .vitepress/locales/en/gitlog.ts | 7 + .vitepress/locales/en/index.ts | 2 + .vitepress/locales/ja/docs-feedback.ts | 2 +- .vitepress/locales/ja/gitlog.ts | 7 + .vitepress/locales/ja/index.ts | 2 + .vitepress/locales/types.ts | 5 +- .vitepress/locales/zh/docs-feedback.ts | 2 +- .vitepress/locales/zh/gitlog.ts | 7 + .vitepress/locales/zh/index.ts | 2 + .vitepress/theme/apis/pageview.ts | 18 - .vitepress/theme/components/Card.vue | 7 +- .vitepress/theme/components/DocInfo.vue | 28 +- .vitepress/theme/index.ts | 24 +- .vitepress/theme/styles/card.scss | 2 +- .vitepress/theme/styles/main.css | 4 + .vitepress/theme/utils.ts | 15 + package.json | 78 +- pnpm-lock.yaml | 3461 ++++++++++++++--------- src/zh/md-enhance-guide.md | 33 +- tsconfig.json | 25 +- 23 files changed, 2338 insertions(+), 1452 deletions(-) create mode 100644 .vitepress/locales/en/gitlog.ts create mode 100644 .vitepress/locales/ja/gitlog.ts create mode 100644 .vitepress/locales/zh/gitlog.ts delete mode 100644 .vitepress/theme/apis/pageview.ts diff --git a/.gitattributes b/.gitattributes index ed4c1d632..17c6c2d60 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,3 +12,8 @@ *.ttf binary *.woff binary *.woff2 binary + +*.md linguist-vendored=false +*.md linguist-generated=false +*.md linguist-documentation=false +*.md linguist-detectable=true diff --git a/.vitepress/config.ts b/.vitepress/config.ts index 5a808900c..e89c34d43 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -1,6 +1,12 @@ import Unocss from 'unocss/vite' +import { cwd } from 'node:process' +import { BiDirectionalLinks } from '@nolebase/markdown-it-bi-directional-links' +import { InlineLinkPreviewElementTransform } from '@nolebase/vitepress-plugin-inline-link-preview/markdown-it' import MarkdownItFootnote from 'markdown-it-footnote' -import MarkdownItKbd from 'markdown-it-kbd-better' +import { + GitChangelog, + GitChangelogMarkdownSection, +} from '@nolebase/vitepress-plugin-git-changelog/vite' import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vitepress' import type { @@ -26,6 +32,7 @@ import { timeline } from './theme/markdown/timeline' import { enConfig } from './locales/en' import { zhConfig } from './locales/zh' import { jaConfig } from './locales/ja' +import path from 'node:path' const isProd = process.env.NODE_ENV === 'production' const commitRef = process.env.COMMIT_REF?.slice(0, 8) || 'dev' @@ -167,7 +174,7 @@ export default defineConfig({ srcExclude: [], scrollOffset: 'header', cleanUrls: true, - lastUpdated: true, + lastUpdated: false, sitemap: { hostname: 'https://yuanshen.site', }, @@ -387,6 +394,9 @@ export default defineConfig({ allow: ['../..'], }, }, + optimizeDeps: { + exclude: ['@nolebase/vitepress-plugin-git-changelog/client'], + }, resolve: { alias: [ { @@ -397,9 +407,22 @@ export default defineConfig({ }, ], }, + ssr: { + noExternal: [ + // If there are other packages that need to be processed by Vite, you can add them here. + '@nolebase/vitepress-plugin-highlight-targeted-heading', + '@nolebase/vitepress-plugin-git-changelog', + ], + }, plugins: [ // https://github.com/antfu/unocss Unocss(), + GitChangelog({ + // Fill in your repository URL here + repoURL: () => + 'https://github.com/https://github.com/kongying-tavern/docs', + }), + GitChangelogMarkdownSection(), ], json: { stringify: true, @@ -410,6 +433,11 @@ export default defineConfig({ image: { lazyLoading: true, }, + preConfig(md) { + // md.use(BiDirectionalLinks({ + // dir: cwd(), + // })) + }, config(md) { md.use(MarkdownItFootnote) md.use(colorPreviewPlugin) @@ -421,13 +449,19 @@ export default defineConfig({ md.use(obsidianImageSize) md.use(figure) md.use(timeline) - md.use(MarkdownItKbd, { - presets: [ - { - name: 'icons', - }, - ], - }) + md.use(InlineLinkPreviewElementTransform) + md.use( + BiDirectionalLinks({ + dir: path.join(cwd(), '/src'), + }), + ) + // md.use(MarkdownItKbd, { + // presets: [ + // { + // name: 'icons', + // }, + // ], + // }) }, }, }) diff --git a/.vitepress/locales/en/docs-feedback.ts b/.vitepress/locales/en/docs-feedback.ts index ada8296ae..312f0ec14 100644 --- a/.vitepress/locales/en/docs-feedback.ts +++ b/.vitepress/locales/en/docs-feedback.ts @@ -12,7 +12,7 @@ const docsFeedback: CustomConfig['docsFeedback'] = { chooseIssues: 'Did you encounter these issues?', translationIssue: 'Translation', typosIssue: 'Typos/Punctuation', - ContentImgLinkIssue: 'Inaccurate Content, Image or Link', + contentImgLinkIssue: 'Inaccurate Content, Image or Link', feedbackDetail: 'Details/Suggestions', feedbackTip: 'Describe issues or suggestions here', otherIssue: 'Other (specify below)', diff --git a/.vitepress/locales/en/gitlog.ts b/.vitepress/locales/en/gitlog.ts new file mode 100644 index 000000000..3b2689505 --- /dev/null +++ b/.vitepress/locales/en/gitlog.ts @@ -0,0 +1,7 @@ +import type { CustomConfig } from '../types' + +const gitlog: CustomConfig['gitlog'] = { + title: 'Contributors', +} + +export default gitlog diff --git a/.vitepress/locales/en/index.ts b/.vitepress/locales/en/index.ts index a85f2ec6b..98e0e01f2 100644 --- a/.vitepress/locales/en/index.ts +++ b/.vitepress/locales/en/index.ts @@ -17,6 +17,7 @@ import DocsFeedback from './docs-feedback' import Staff from './staff' import Team from './team' import Payment from './payment' +import gitlog from './gitlog' export const enConfig: LocaleSpecificConfig< DefaultTheme.Config & CustomConfig @@ -48,6 +49,7 @@ export const enConfig: LocaleSpecificConfig< staff: Staff, team: Team, payment: Payment, + gitlog: gitlog, nav: baseHelper(Nav, C.LOCAL_BASE), sidebar: baseHelper(Sidebar, C.LOCAL_BASE), diff --git a/.vitepress/locales/ja/docs-feedback.ts b/.vitepress/locales/ja/docs-feedback.ts index 4233af166..e817ddb3e 100644 --- a/.vitepress/locales/ja/docs-feedback.ts +++ b/.vitepress/locales/ja/docs-feedback.ts @@ -13,7 +13,7 @@ const docsFeedback: CustomConfig['docsFeedback'] = { chooseIssues: '以下の問題に遭遇しましたか?', translationIssue: '翻訳の問題', typosIssue: '誤字/句読点のエラー', - ContentImgLinkIssue: + contentImgLinkIssue: '不正確なコンテンツ表現、画像読み込みエラー、またはリンクエラー', feedbackDetail: '詳細/提案', feedbackTip: 'ここに遭遇した問題や提案を説明してください', diff --git a/.vitepress/locales/ja/gitlog.ts b/.vitepress/locales/ja/gitlog.ts new file mode 100644 index 000000000..d65cd2384 --- /dev/null +++ b/.vitepress/locales/ja/gitlog.ts @@ -0,0 +1,7 @@ +import type { CustomConfig } from '../types' + +const gitlog: CustomConfig['gitlog'] = { + title: '寄稿者', +} + +export default gitlog diff --git a/.vitepress/locales/ja/index.ts b/.vitepress/locales/ja/index.ts index 478cb67a5..93ead7b7e 100644 --- a/.vitepress/locales/ja/index.ts +++ b/.vitepress/locales/ja/index.ts @@ -17,6 +17,7 @@ import DocsFeedback from './docs-feedback' import Staff from './staff' import Team from './team' import Payment from './payment' +import gitlog from './gitlog' export const jaConfig: LocaleSpecificConfig< DefaultTheme.Config & CustomConfig @@ -48,6 +49,7 @@ export const jaConfig: LocaleSpecificConfig< staff: Staff, team: Team, payment: Payment, + gitlog: gitlog, nav: baseHelper(Nav, C.LOCAL_BASE), sidebar: baseHelper(Sidebar, C.LOCAL_BASE), diff --git a/.vitepress/locales/types.ts b/.vitepress/locales/types.ts index 642ebe0df..c60843b51 100644 --- a/.vitepress/locales/types.ts +++ b/.vitepress/locales/types.ts @@ -76,7 +76,7 @@ export interface CustomConfig { chooseIssues: string translationIssue: string typosIssue: string - ContentImgLinkIssue: string + contentImgLinkIssue: string feedbackDetail: string feedbackTip: string otherIssue: string @@ -87,6 +87,9 @@ export interface CustomConfig { }[] } } + gitlog: { + title: string + } } export interface CustomConstant { diff --git a/.vitepress/locales/zh/docs-feedback.ts b/.vitepress/locales/zh/docs-feedback.ts index 482842665..d680951d7 100644 --- a/.vitepress/locales/zh/docs-feedback.ts +++ b/.vitepress/locales/zh/docs-feedback.ts @@ -11,7 +11,7 @@ const docsFeedback: CustomConfig['docsFeedback'] = { chooseIssues: '是否遇到以下问题?', translationIssue: '翻译问题', typosIssue: '错别字/标点符号', - ContentImgLinkIssue: '文案表达不准确、图片加载失败或链接错误', + contentImgLinkIssue: '文案表达不准确、图片加载失败或链接错误', feedbackDetail: '反馈内容/更多建议', feedbackTip: '请详细描述你在使用文档过程中遇到的问题或优化建议', otherIssue: '其他问题(请在反馈内容中具体描述)', diff --git a/.vitepress/locales/zh/gitlog.ts b/.vitepress/locales/zh/gitlog.ts new file mode 100644 index 000000000..d4a00d698 --- /dev/null +++ b/.vitepress/locales/zh/gitlog.ts @@ -0,0 +1,7 @@ +import type { CustomConfig } from '../types' + +const gitlog: CustomConfig['gitlog'] = { + title: '贡献者', +} + +export default gitlog diff --git a/.vitepress/locales/zh/index.ts b/.vitepress/locales/zh/index.ts index 49167aabe..d822d9771 100644 --- a/.vitepress/locales/zh/index.ts +++ b/.vitepress/locales/zh/index.ts @@ -17,6 +17,7 @@ import DocsFeedback from './docs-feedback' import Staff from './staff' import Team from './team' import Payment from './payment' +import gitlog from './gitlog' export const zhConfig: LocaleSpecificConfig< DefaultTheme.Config & CustomConfig @@ -48,6 +49,7 @@ export const zhConfig: LocaleSpecificConfig< staff: Staff, team: Team, payment: Payment, + gitlog: gitlog, nav: baseHelper(Nav, C.LOCAL_BASE), sidebar: baseHelper(Sidebar, C.LOCAL_BASE), diff --git a/.vitepress/theme/apis/pageview.ts b/.vitepress/theme/apis/pageview.ts deleted file mode 100644 index f5e958828..000000000 --- a/.vitepress/theme/apis/pageview.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { fetcher } from '.' - -export type PageviewResponse = { - code: number - message?: string -} - -export const pageview = async (record_id): Promise => { - // @ts-ignore - if (import.meta.env.SSR) return null - return await fetcher - .get('docs/pageview', { - searchParams: { - record_id, - }, - }) - .json() -} diff --git a/.vitepress/theme/components/Card.vue b/.vitepress/theme/components/Card.vue index c29224b3a..316e26569 100644 --- a/.vitepress/theme/components/Card.vue +++ b/.vitepress/theme/components/Card.vue @@ -56,7 +56,7 @@ +: { target: any; }: { target: any; }: { target: any; }: { target: any; } diff --git a/.vitepress/theme/components/DocInfo.vue b/.vitepress/theme/components/DocInfo.vue index 76d99b7c1..20ecd04d0 100644 --- a/.vitepress/theme/components/DocInfo.vue +++ b/.vitepress/theme/components/DocInfo.vue @@ -1,5 +1,10 @@