From 56fbafd53b6ce243cd16be5e1eba8316c2119cea Mon Sep 17 00:00:00 2001 From: Rocka Date: Fri, 13 Dec 2024 23:33:18 +0800 Subject: [PATCH] refactor(docs): refine vitepress config --- docs/.vitepress/config/en.ts | 94 ++++++++++++++-------------- docs/.vitepress/config/index.ts | 49 +++++++++++++-- docs/.vitepress/config/shared.ts | 34 ---------- docs/.vitepress/config/types.d.ts | 6 ++ docs/.vitepress/config/zh.ts | 100 +++++++++++++++--------------- 5 files changed, 150 insertions(+), 133 deletions(-) delete mode 100644 docs/.vitepress/config/shared.ts create mode 100644 docs/.vitepress/config/types.d.ts diff --git a/docs/.vitepress/config/en.ts b/docs/.vitepress/config/en.ts index dec3372a..51e62d0d 100644 --- a/docs/.vitepress/config/en.ts +++ b/docs/.vitepress/config/en.ts @@ -1,7 +1,8 @@ -import { defineConfig } from 'vitepress'; +import { type LocaleConfig } from './types'; -export const en = defineConfig({ +export const en: LocaleConfig = { lang: 'en-US', + label: 'English', description: 'A very simple, high performance, edge WebRTC SFU', themeConfig: { @@ -11,48 +12,51 @@ export const en = defineConfig({ ], sidebar: { - '/guide/': { base: '/guide/', items: [ - { - text: 'Introduction', - collapsed: false, - items: [ - { text: 'What is live777 ?', link: 'what-is-live777' }, - { text: 'Installation', link: 'installation' }, - { text: 'Getting Started', link: 'getting-started' }, - { text: 'For developer', link: 'developer' }, - ] - }, - { - text: 'Components', - collapsed: false, - items: [ - { text: 'Live777', link: 'live777' }, - { text: 'Web UI', link: 'webui' }, - { text: 'LiveMan', link: 'liveman' }, - { text: 'WhipInto', link: 'whipinto' }, - { text: 'WhepFrom', link: 'whepfrom' }, - { text: 'NET4MQTT', link: 'net4mqtt' }, - ] - }, - { - text: 'Example', - collapsed: false, - items: [ - { text: 'OBS Studio', link: 'obs-studio' }, - { text: 'FFmpeg', link: 'ffmpeg' }, - { text: 'Gstreamer', link: 'gstreamer' }, - { text: 'VLC', link: 'vlc' }, - ] - }, - { - text: 'Reference', - collapsed: false, - items: [ - { text: 'Live777 API', link: 'live777-api' }, - { text: 'LiveMan API', link: 'liveman-api' }, - ] - } - ]}, + '/guide/': { + base: '/guide/', + items: [ + { + text: 'Introduction', + collapsed: false, + items: [ + { text: 'What is live777 ?', link: 'what-is-live777' }, + { text: 'Installation', link: 'installation' }, + { text: 'Getting Started', link: 'getting-started' }, + { text: 'For developer', link: 'developer' }, + ] + }, + { + text: 'Components', + collapsed: false, + items: [ + { text: 'Live777', link: 'live777' }, + { text: 'Web UI', link: 'webui' }, + { text: 'LiveMan', link: 'liveman' }, + { text: 'WhipInto', link: 'whipinto' }, + { text: 'WhepFrom', link: 'whepfrom' }, + { text: 'NET4MQTT', link: 'net4mqtt' }, + ] + }, + { + text: 'Example', + collapsed: false, + items: [ + { text: 'OBS Studio', link: 'obs-studio' }, + { text: 'FFmpeg', link: 'ffmpeg' }, + { text: 'Gstreamer', link: 'gstreamer' }, + { text: 'VLC', link: 'vlc' }, + ] + }, + { + text: 'Reference', + collapsed: false, + items: [ + { text: 'Live777 API', link: 'live777-api' }, + { text: 'LiveMan API', link: 'liveman-api' }, + ] + } + ] + }, }, } -}); +}; diff --git a/docs/.vitepress/config/index.ts b/docs/.vitepress/config/index.ts index 910059fe..4b17ddce 100644 --- a/docs/.vitepress/config/index.ts +++ b/docs/.vitepress/config/index.ts @@ -1,13 +1,52 @@ import { defineConfig } from 'vitepress'; -import { shared } from './shared'; + import { en } from './en'; import { zh } from './zh'; -// https://vitepress.dev/reference/site-config +/** + * @see https://vitepress.dev/reference/site-config + */ export default defineConfig({ - ...shared, + title: 'Live777', + + lastUpdated: true, + cleanUrls: true, + metaChunk: true, + + head: [ + ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }], + ['meta', { name: 'theme-color', content: '#5f67ee' }], + ['meta', { property: 'og:type', content: 'website' }], + ['meta', { property: 'og:locale', content: 'en' }], + ['meta', { property: 'og:title', content: 'Live777 | A very simple, high performance, edge WebRTC SFU' }], + ['meta', { property: 'og:site_name', content: 'VitePress' }], + ['meta', { property: 'og:image', content: 'https://live777.binbat.com/logo.svg' }], + ['meta', { property: 'og:url', content: 'https://live777.binbat.com/' }], + ], + + themeConfig: { + logo: { src: '/logo.svg', width: 24, height: 24 }, + + socialLinks: [ + { icon: 'github', link: 'https://github.com/binbat/live777' } + ], + + footer: { + message: 'Released under the MPL-2.0 License.', + copyright: 'Copyright © 2023-present BinBat LTD' + } + }, + locales: { - root: { label: 'English', ...en }, - zh: { label: '简体中文', ...zh }, + root: en, + zh, + }, + + vite: { + css: { + postcss: { + // don't need postcss in docs + } + } } }); diff --git a/docs/.vitepress/config/shared.ts b/docs/.vitepress/config/shared.ts deleted file mode 100644 index 36a4e516..00000000 --- a/docs/.vitepress/config/shared.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { defineConfig } from 'vitepress'; - -export const shared = defineConfig({ - title: 'Live777', - - lastUpdated: true, - cleanUrls: true, - metaChunk: true, - - /* prettier-ignore */ - head: [ - ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }], - ['meta', { name: 'theme-color', content: '#5f67ee' }], - ['meta', { property: 'og:type', content: 'website' }], - ['meta', { property: 'og:locale', content: 'en' }], - ['meta', { property: 'og:title', content: 'Live777 | A very simple, high performance, edge WebRTC SFU' }], - ['meta', { property: 'og:site_name', content: 'VitePress' }], - ['meta', { property: 'og:image', content: 'https://live777.binbat.com/logo.svg' }], - ['meta', { property: 'og:url', content: 'https://live777.binbat.com/' }], - ], - - themeConfig: { - logo: { src: '/logo.svg', width: 24, height: 24 }, - - socialLinks: [ - { icon: 'github', link: 'https://github.com/binbat/live777' } - ], - - footer: { - message: 'Released under the MPL-2.0 License.', - copyright: 'Copyright © 2023-present BinBat LTD' - } - } -}); diff --git a/docs/.vitepress/config/types.d.ts b/docs/.vitepress/config/types.d.ts new file mode 100644 index 00000000..ded54724 --- /dev/null +++ b/docs/.vitepress/config/types.d.ts @@ -0,0 +1,6 @@ +import { defineConfig } from 'vitepress'; + +type LocalesType = NonNullable[0]['locales']>; +type LocalesValueType = LocalesType[keyof LocalesType]; + +export type LocaleConfig = LocalesValueType; diff --git a/docs/.vitepress/config/zh.ts b/docs/.vitepress/config/zh.ts index 02fcb2df..059a5595 100644 --- a/docs/.vitepress/config/zh.ts +++ b/docs/.vitepress/config/zh.ts @@ -1,60 +1,62 @@ +import { type LocaleConfig } from './types'; -import { defineConfig } from 'vitepress'; - -export const zh = defineConfig({ +export const zh: LocaleConfig = { lang: 'zh-Hans', + label: '简体中文', description: '简单,高性能,WebRTC SFU', themeConfig: { nav: [ - { text: 'Home', link: '/' }, - { text: '指引', link: '/guide/what-is-live777' } + { text: '主页', link: '/zh/' }, + { text: '指引', link: '/zh/guide/what-is-live777' } ], - sidebar: { - '/zh/guide/': { base: '/zh/guide/', items: [ - { - text: '简介', - collapsed: false, - items: [ - { text: '什么是 Live777 ?', link: 'what-is-live777' }, - { text: '安装部署', link: 'installation' }, - { text: '快速开始', link: 'getting-started' }, - { text: '开发者', link: 'developer' }, - ] - }, - { - text: '组件', - collapsed: false, - items: [ - { text: 'Live777', link: 'live777' }, - { text: 'Web UI', link: 'webui' }, - { text: 'LiveMan', link: 'liveman' }, - { text: 'WhipInto', link: 'whipinto' }, - { text: 'WhepFrom', link: 'whepfrom' }, - { text: 'NET4MQTT', link: 'net4mqtt' }, - ] - }, - { - text: '例子', - collapsed: false, - items: [ - { text: 'OBS Studio', link: 'obs-studio' }, - { text: 'FFmpeg', link: 'ffmpeg' }, - { text: 'Gstreamer', link: 'gstreamer' }, - { text: 'VLC', link: 'vlc' }, - ] - }, - { - text: '参考', - collapsed: false, - items: [ - { text: 'Live777 API', link: 'live777-api' }, - { text: 'LiveMan API', link: 'liveman-api' }, - ] - } - ]}, + '/zh/guide/': { + base: '/zh/guide/', + items: [ + { + text: '简介', + collapsed: false, + items: [ + { text: '什么是 Live777 ?', link: 'what-is-live777' }, + { text: '安装部署', link: 'installation' }, + { text: '快速开始', link: 'getting-started' }, + { text: '开发者', link: 'developer' }, + ] + }, + { + text: '组件', + collapsed: false, + items: [ + { text: 'Live777', link: 'live777' }, + { text: 'Web UI', link: 'webui' }, + { text: 'LiveMan', link: 'liveman' }, + { text: 'WhipInto', link: 'whipinto' }, + { text: 'WhepFrom', link: 'whepfrom' }, + { text: 'NET4MQTT', link: 'net4mqtt' }, + ] + }, + { + text: '例子', + collapsed: false, + items: [ + { text: 'OBS Studio', link: 'obs-studio' }, + { text: 'FFmpeg', link: 'ffmpeg' }, + { text: 'Gstreamer', link: 'gstreamer' }, + { text: 'VLC', link: 'vlc' }, + ] + }, + { + text: '参考', + collapsed: false, + items: [ + { text: 'Live777 API', link: 'live777-api' }, + { text: 'LiveMan API', link: 'liveman-api' }, + ] + } + ] + }, }, } -}); +};