From db2facce18af6198d8638b9ea0850ce487056a14 Mon Sep 17 00:00:00 2001 From: iMaeGoo Date: Mon, 14 Aug 2023 17:55:07 +0800 Subject: [PATCH] docs: use vitepress --- .github/workflows/docs.yml | 2 +- .gitignore | 4 +- docs/.vitepress/config.ts | 54 +++++++++++++++++ docs/.vitepress/theme/Layout.vue | 81 +++++++++++++++++++++++++ docs/.vitepress/theme/index.ts | 9 +++ docs/.vuepress/config.js | 56 ----------------- docs/.vuepress/theme/index.js | 16 ----- docs/.vuepress/theme/layouts/Layout.vue | 81 ------------------------- docs/en/{README.md => index.md} | 26 ++++++-- docs/{README.md => index.md} | 26 ++++++-- docs/package.json | 8 +-- 11 files changed, 194 insertions(+), 169 deletions(-) create mode 100644 docs/.vitepress/config.ts create mode 100644 docs/.vitepress/theme/Layout.vue create mode 100644 docs/.vitepress/theme/index.ts delete mode 100644 docs/.vuepress/config.js delete mode 100644 docs/.vuepress/theme/index.js delete mode 100644 docs/.vuepress/theme/layouts/Layout.vue rename docs/en/{README.md => index.md} (85%) rename docs/{README.md => index.md} (87%) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 986b35484..0a674de38 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,5 +22,5 @@ jobs: TARGET_REPO: imaegoo/twikoo TARGET_BRANCH: gh-pages BUILD_SCRIPT: cd docs && yarn && yarn docs:build - BUILD_DIR: .vuepress/dist + BUILD_DIR: .vitepress/dist CNAME: twikoo.js.org diff --git a/.gitignore b/.gitignore index 4484acda9..e44be7ff4 100644 --- a/.gitignore +++ b/.gitignore @@ -92,7 +92,9 @@ dist # public # vuepress build output -.vuepress/dist +docs/.vuepress/dist +docs/.vitepress/dist +docs/.vitepress/cache # Serverless directories .serverless/ diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts new file mode 100644 index 000000000..3da852a94 --- /dev/null +++ b/docs/.vitepress/config.ts @@ -0,0 +1,54 @@ +import { defineConfig } from 'vitepress' + +// https://vitepress.dev/reference/site-config +export default defineConfig({ + locales: { + root: { + label: '简体中文', + lang: 'zh-CN', + title: 'Twikoo 文档', + description: 'Twikoo 文档', + themeConfig: { + sidebar: [ + { text: '简介', link: '/' }, + { text: '快速上手', link: '/quick-start' }, + { text: '常见问题', link: '/faq' }, + { text: 'API 文档', link: '/api' }, + { text: '相关文档', link: '/link' } + ] + } + }, + en: { + label: 'English (US)', + lang: 'en', + link: '/en/', + title: 'Twikoo Docs', + description: 'Twikoo Docs', + themeConfig: { + sidebar: [ + { text: 'Introduction', link: '/en/' }, + { text: 'Quick start', link: '/en/quick-start' }, + { text: 'FAQ', link: '/en/faq' }, + { text: 'API', link: '/en/api' } + ] + } + } + }, + themeConfig: { + search: { + provider: 'algolia', + options: { + appId: 'TM627WNO90', + apiKey: 'f81194a47bc4be7984df25fc480c60a7', + indexName: 'twikoo' + } + }, + socialLinks: [ + { icon: 'github', link: 'https://github.com/imaegoo/twikoo' } + ], + editLink: { + pattern: 'https://github.com/imaegoo/twikoo/edit/main/docs/:path' + } + }, + lastUpdated: true +}) diff --git a/docs/.vitepress/theme/Layout.vue b/docs/.vitepress/theme/Layout.vue new file mode 100644 index 000000000..2612ffafc --- /dev/null +++ b/docs/.vitepress/theme/Layout.vue @@ -0,0 +1,81 @@ + + + diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts new file mode 100644 index 000000000..9c6fd9e55 --- /dev/null +++ b/docs/.vitepress/theme/index.ts @@ -0,0 +1,9 @@ +import DefaultTheme from 'vitepress/theme' +import Layout from './Layout.vue' + +export default { + ...DefaultTheme, + // override the Layout with a wrapper component that + // injects the slots + Layout +} diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js deleted file mode 100644 index 3c31f58bc..000000000 --- a/docs/.vuepress/config.js +++ /dev/null @@ -1,56 +0,0 @@ -const { docsearchPlugin } = require('@vuepress/plugin-docsearch') -const twikooTheme = require('./theme') - -module.exports = { - locales: { - // 键名是该语言所属的子路径 - // 作为特例,默认语言可以使用 '/' 作为其路径。 - '/': { - lang: 'zh-CN', - title: 'Twikoo 文档', - description: 'Twikoo 文档' - }, - '/en/': { - lang: 'en-US', - title: 'Twikoo Docs', - description: 'Twikoo Docs' - } - }, - theme: twikooTheme({ - locales: { - '/': { - selectLanguageName: '简体中文', - sidebar: [ - { text: '简介', link: '/' }, - '/quick-start', - '/faq', - '/api', - '/link' - ] - }, - '/en/': { - selectLanguageName: 'English (US)', - sidebar: [ - { text: 'Introduction', link: '/en/' }, - '/en/quick-start', - '/en/faq', - '/en/api' - ] - } - }, - lastUpdated: true, - // 假定是 GitHub. 同时也可以是一个完整的 GitLab URL - repo: 'imaegoo/twikoo', - // 假如文档不是放在仓库的根目录下: - docsDir: 'docs', - // 假如文档放在一个特定的分支下: - docsBranch: 'main' - }), - plugins: [ - docsearchPlugin({ - appId: 'TM627WNO90', - apiKey: 'f81194a47bc4be7984df25fc480c60a7', - indexName: 'twikoo' - }) - ] -} diff --git a/docs/.vuepress/theme/index.js b/docs/.vuepress/theme/index.js deleted file mode 100644 index fc8b5396e..000000000 --- a/docs/.vuepress/theme/index.js +++ /dev/null @@ -1,16 +0,0 @@ -const { defaultTheme } = require('@vuepress/theme-default') -const { path } = require('@vuepress/utils') - -/** - * 继承 VuePress 默认主题,并在 page-bottom 插槽中显示评论区 - * https://v2.vuepress.vuejs.org/zh/reference/default-theme/extending.html - */ -module.exports = (options) => { - return { - name: 'vuepress-theme-twikoo', - extends: defaultTheme(options), - layouts: { - Layout: path.resolve(__dirname, 'layouts/Layout.vue'), - } - } -} diff --git a/docs/.vuepress/theme/layouts/Layout.vue b/docs/.vuepress/theme/layouts/Layout.vue deleted file mode 100644 index f7ef780d4..000000000 --- a/docs/.vuepress/theme/layouts/Layout.vue +++ /dev/null @@ -1,81 +0,0 @@ - - - diff --git a/docs/en/README.md b/docs/en/index.md similarity index 85% rename from docs/en/README.md rename to docs/en/index.md index 16d46b228..c928b5664 100644 --- a/docs/en/README.md +++ b/docs/en/index.md @@ -2,11 +2,27 @@ ---- -[![](https://img.shields.io/npm/v/twikoo)](https://www.npmjs.com/package/twikoo) -[![](https://img.shields.io/bundlephobia/minzip/twikoo)](https://bundlephobia.com/result?p=twikoo) -[![](https://img.shields.io/npm/dt/twikoo)](https://www.npmjs.com/package/twikoo) -[![](https://data.jsdelivr.com/v1/package/npm/twikoo/badge)](https://www.jsdelivr.com/package/npm/twikoo) -[![](https://img.shields.io/npm/l/twikoo)](https://github.com/imaegoo/twikoo/blob/main/LICENSE) + + + +   + + +   + + +   + + +   + + + + A **simple**, **safe**, **free** comment system. [简体中文](/) | **English** diff --git a/docs/README.md b/docs/index.md similarity index 87% rename from docs/README.md rename to docs/index.md index 44dfe8e0f..dbdcc2c0c 100644 --- a/docs/README.md +++ b/docs/index.md @@ -2,11 +2,27 @@ ---- -[![](https://img.shields.io/npm/v/twikoo)](https://www.npmjs.com/package/twikoo) -[![](https://img.shields.io/bundlephobia/minzip/twikoo)](https://bundlephobia.com/result?p=twikoo) -[![](https://img.shields.io/npm/dt/twikoo)](https://www.npmjs.com/package/twikoo) -[![](https://data.jsdelivr.com/v1/package/npm/twikoo/badge)](https://www.jsdelivr.com/package/npm/twikoo) -[![](https://img.shields.io/npm/l/twikoo)](https://github.com/imaegoo/twikoo/blob/main/LICENSE) + + + +   + + +   + + +   + + +   + + + + 一个简洁、安全、免费的静态网站评论系统。
A simple, safe, free comment system. diff --git a/docs/package.json b/docs/package.json index 2fcb78276..e3f457f56 100644 --- a/docs/package.json +++ b/docs/package.json @@ -3,17 +3,17 @@ "author": "imaegoo (https://github.com/imaegoo)", "license": "MIT", "private": true, + "type": "module", "repository": { "type": "git", "url": "https://github.com/imaegoo/twikoo.git" }, "homepage": "https://twikoo.js.org", "scripts": { - "docs:dev": "vuepress dev .", - "docs:build": "vuepress build ." + "docs:dev": "vitepress", + "docs:build": "vitepress build" }, "devDependencies": { - "@vuepress/plugin-docsearch": "2.0.0-beta.49", - "vuepress": "2.0.0-beta.49" + "vitepress": "^1.0.0-rc.4" } }