diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 2143ae51a..fe5049258 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -1,3 +1,4 @@ +import { fileURLToPath } from 'node:url' import consola from 'consola' import UnoCSS from 'unocss/vite' import AutoImport from 'unplugin-auto-import/vite' @@ -8,6 +9,7 @@ import { commitRef, feedback, meta, + nav, search, sidebar, socialLinks @@ -58,6 +60,16 @@ export default defineConfig({ ssr: { noExternal: ['@fmhy/components'] }, + resolve: { + alias: [ + { + find: /^.*VPSwitchAppearance\.vue$/, + replacement: fileURLToPath( + new URL('./theme/Appearance.vue', import.meta.url) + ) + } + ] + }, optimizeDeps: { exclude: ['workbox-window'] }, plugins: [ OptimizeExclude(), @@ -121,29 +133,7 @@ export default defineConfig({ }, outline: 'deep', logo: '/fmhy.ico', - nav: [ - { text: '🔖 Glossary', link: 'https://rentry.org/The-Piracy-Glossary' }, - { text: '📑 Guides', link: 'https://rentry.co/fmhy-guides' }, - { - text: '💾 Backups', - link: 'https://github.com/fmhy/FMHY/wiki/Backups' - }, - { - text: '🪅 Ecosystem', - items: [ - { text: '💙 Feedback', link: '/feedback' }, - { text: '🌐 Search', link: '/posts/search' }, - { text: '🏞 Wallpapers', link: '/other/wallpapers' }, - { text: '📋 snowbin', link: 'https://pastes.fmhy.net' }, - { text: '🔍 SearXNG', link: 'https://searx.fmhy.net/' }, - { text: '🔍 Whoogle', link: 'https://whoogle.fmhy.net/' }, - { - text: '🔗 Bookmarks', - link: 'https://github.com/fmhy/bookmarks' - } - ] - } - ], + nav, sidebar, socialLinks } diff --git a/docs/.vitepress/constants.ts b/docs/.vitepress/constants.ts index e8e2eda05..b52cf9315 100644 --- a/docs/.vitepress/constants.ts +++ b/docs/.vitepress/constants.ts @@ -28,8 +28,9 @@ export const meta = { export const commitRef = process.env.CF_PAGES && process.env.CF_PAGES_COMMIT_SHA - ? `${process.env.CF_PAGES_COMMIT_SHA.slice(0, 8)}` + ? `${process.env.CF_PAGES_COMMIT_SHA.slice(0, 8)}` : 'dev' export const feedback = `Made with ❤` @@ -113,7 +114,10 @@ export const socialLinks: DefaultTheme.SocialLink[] = [ { icon: 'github', link: 'https://github.com/fmhy/FMHYEdit' }, { icon: 'discord', link: 'https://discord.gg/Stz6y6NgNg' }, { - icon: 'reddit', + ariaLabel: 'Reddit', + icon: { + svg: 'Reddit' + }, link: 'https://reddit.com/r/FREEMEDIAHECKYEAH' }, { @@ -125,6 +129,30 @@ export const socialLinks: DefaultTheme.SocialLink[] = [ } ] +export const nav: DefaultTheme.NavItem[] = [ + { text: '🔖 Glossary', link: 'https://rentry.org/The-Piracy-Glossary' }, + { text: '📑 Guides', link: 'https://rentry.co/fmhy-guides' }, + { + text: '💾 Backups', + link: 'https://github.com/fmhy/FMHY/wiki/Backups' + }, + { + text: '🪅 Ecosystem', + items: [ + { text: '💙 Feedback', link: '/feedback' }, + { text: '🌐 Search', link: '/posts/search' }, + { text: '🏞 Wallpapers', link: '/other/wallpapers' }, + { text: '📋 snowbin', link: 'https://pastes.fmhy.net' }, + { text: '🔍 SearXNG', link: 'https://searx.fmhy.net/' }, + { text: '🔍 Whoogle', link: 'https://whoogle.fmhy.net/' }, + { + text: '🔗 Bookmarks', + link: 'https://github.com/fmhy/bookmarks' + } + ] + } +] + export const sidebar: DefaultTheme.Sidebar | DefaultTheme.NavItemWithLink[] = [ { text: ' Beginners Guide', diff --git a/docs/.vitepress/hooks/meta.ts b/docs/.vitepress/hooks/meta.ts index b5f72c498..1269fdf74 100644 --- a/docs/.vitepress/hooks/meta.ts +++ b/docs/.vitepress/hooks/meta.ts @@ -20,6 +20,8 @@ export function generateMeta(context: TransformContext, hostname: string) { const head: HeadConfig[] = [] const { pageData } = context + if (pageData.isNotFound) return head + const url = `${hostname}/${pageData.relativePath.replace(/((^|\/)index)?\.md$/, '$2')}` head.push( @@ -30,6 +32,7 @@ export function generateMeta(context: TransformContext, hostname: string) { ['meta', { property: 'og:title', content: pageData.frontmatter.title }], ['meta', { name: 'twitter:title', content: pageData.frontmatter.title }] ) + if (pageData.frontmatter.description) { head.push( [ @@ -48,6 +51,7 @@ export function generateMeta(context: TransformContext, hostname: string) { ] ) } + if (pageData.frontmatter.image) { head.push([ 'meta', @@ -87,12 +91,14 @@ export function generateMeta(context: TransformContext, hostname: string) { ] ) } + if (pageData.frontmatter.tag) { head.push([ 'meta', { property: 'article:tag', content: pageData.frontmatter.tag } ]) } + if (pageData.frontmatter.date) { head.push([ 'meta', @@ -102,6 +108,7 @@ export function generateMeta(context: TransformContext, hostname: string) { } ]) } + if (pageData.lastUpdated && pageData.frontmatter.lastUpdated !== false) { head.push([ 'meta', diff --git a/docs/.vitepress/theme/Appearance.vue b/docs/.vitepress/theme/Appearance.vue new file mode 100644 index 000000000..d2a81f015 --- /dev/null +++ b/docs/.vitepress/theme/Appearance.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/docs/.vitepress/theme/Layout.vue b/docs/.vitepress/theme/Layout.vue index 8b047f114..4f37b3b8c 100644 --- a/docs/.vitepress/theme/Layout.vue +++ b/docs/.vitepress/theme/Layout.vue @@ -47,7 +47,7 @@ const { Layout } = DefaultTheme -