Commit d3d8ac5cd8
Unregistered key
Layout: unified · split
docs/.vitepress/configs/index.ts +68 −71
| @@ -5,104 +5,101 @@ | |||
| 5 | * | 5 | * |
| 6 | * All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder. | 6 | * All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder. |
| 7 | */ | 7 | */ |
| 8 | import type { DefaultTheme, Plugin, UserConfig } from "vitepress"; | 8 | import type { DefaultTheme, Plugin, UserConfig } from 'vitepress' |
| 9 | import { generateImages, generateMeta } from "./hooks"; | 9 | import { generateImages, generateMeta } from './hooks' |
| 10 | import { defs, movePlugin, aliases } from "./markdown/emoji"; | 10 | import { defs, movePlugin, aliases } from './markdown/emoji' |
| 11 | import { | 11 | import { |
| 12 | PageProperties, | 12 | PageProperties, |
| 13 | PagePropertiesMarkdownSection, | 13 | PagePropertiesMarkdownSection |
| 14 | } from "@nolebase/vitepress-plugin-page-properties/vite"; | 14 | } from '@nolebase/vitepress-plugin-page-properties/vite' |
| 15 | import { | 15 | import { |
| 16 | GitChangelog, | 16 | GitChangelog, |
| 17 | GitChangelogMarkdownSection, | 17 | GitChangelogMarkdownSection |
| 18 | } from "@nolebase/vitepress-plugin-git-changelog/vite"; | 18 | } from '@nolebase/vitepress-plugin-git-changelog/vite' |
| 19 | import { fileURLToPath, URL } from "node:url"; | 19 | import { fileURLToPath, URL } from 'node:url' |
| 20 | import UnoCSS from "unocss/vite"; | 20 | import UnoCSS from 'unocss/vite' |
| 21 | import Devtools from "vite-plugin-vue-devtools"; | 21 | import Devtools from 'vite-plugin-vue-devtools' |
| 22 | import { configureMarkdown } from "./markdown"; | 22 | import { configureMarkdown } from './markdown' |
| 23 | import { GIT_COMMIT, hostname, nav, sidebar, siteConfig } from "./constants"; | 23 | import { GIT_COMMIT, hostname, nav, sidebar, siteConfig } from './constants' |
| 24 | 24 | ||
| 25 | export const shared: UserConfig<DefaultTheme.Config> = { | 25 | export const shared: UserConfig<DefaultTheme.Config> = { |
| 26 | ...siteConfig, | 26 | ...siteConfig, |
| 27 | transformHead: async (context) => generateMeta(context, hostname), | 27 | transformHead: async (context) => generateMeta(context, hostname), |
| 28 | buildEnd: async (context) => { | 28 | buildEnd: async (context) => { |
| 29 | generateImages(context); | 29 | generateImages(context) |
| 30 | }, | 30 | }, |
| 31 | markdown: { | 31 | markdown: { |
| 32 | emoji: { defs, shortcuts: aliases }, | 32 | emoji: { defs, shortcuts: aliases }, |
| 33 | config(md) { | 33 | config(md) { |
| 34 | configureMarkdown(md); | 34 | configureMarkdown(md) |
| 35 | }, | 35 | } |
| 36 | }, | 36 | }, |
| 37 | themeConfig: { | 37 | themeConfig: { |
| 38 | search: { | 38 | search: { |
| 39 | options: { | 39 | options: { |
| 40 | miniSearch: { | 40 | miniSearch: { |
| 41 | searchOptions: { | 41 | searchOptions: { |
| 42 | combineWith: "AND", | 42 | combineWith: 'AND', |
| 43 | fuzzy: false, | 43 | fuzzy: false, |
| 44 | // @ts-ignore | 44 | // @ts-ignore |
| 45 | boostDocument: ( | 45 | boostDocument: ( |
| 46 | _, | 46 | _, |
| 47 | term, | 47 | term, |
| 48 | storedFields: Record<string, string | string[]>, | 48 | storedFields: Record<string, string | string[]> |
| 49 | ) => { | 49 | ) => { |
| 50 | const titles = (storedFields?.titles as string[]) | 50 | const titles = (storedFields?.titles as string[]) |
| 51 | .filter((t) => Boolean(t)) | 51 | .filter((t) => Boolean(t)) |
| 52 | .map((t) => t.toLowerCase()); | 52 | .map((t) => t.toLowerCase()) |
| 53 | // Uprate if term appears in titles. Add bonus for higher levels (i.e. lower index) | 53 | // Uprate if term appears in titles. Add bonus for higher levels (i.e. lower index) |
| 54 | const titleIndex = | 54 | const titleIndex = |
| 55 | titles | 55 | titles |
| 56 | .map((t, i) => (t?.includes(term) ? i : -1)) | 56 | .map((t, i) => (t?.includes(term) ? i : -1)) |
| 57 | .find((i) => i >= 0) ?? -1; | 57 | .find((i) => i >= 0) ?? -1 |
| 58 | if (titleIndex >= 0) return 10000 - titleIndex; | 58 | if (titleIndex >= 0) return 10000 - titleIndex |
| 59 | 59 | ||
| 60 | return 1; | 60 | return 1 |
| 61 | }, | 61 | } |
| 62 | }, | 62 | } |
| 63 | }, | 63 | }, |
| 64 | detailedView: true, | 64 | detailedView: true |
| 65 | }, | 65 | }, |
| 66 | provider: "local", | 66 | provider: 'local' |
| 67 | }, | 67 | }, |
| 68 | logo: { src: "/asset/fav.png" }, | 68 | logo: { src: '/asset/fav.png' }, |
| 69 | sidebar, | 69 | sidebar, |
| 70 | nav, | 70 | nav, |
| 71 | socialLinks: [ | 71 | socialLinks: [ |
| 72 | { icon: "github", link: "https://github.com/wotakumoe/Wotaku" }, | 72 | { icon: 'github', link: 'https://github.com/wotakumoe/Wotaku' }, |
| 73 | { icon: "discord", link: "https://discord.gg/vShRGx8ZBC" }, | 73 | { icon: 'discord', link: 'https://discord.gg/vShRGx8ZBC' }, |
| 74 | { | 74 | { |
| 75 | icon: "bluesky", | 75 | icon: 'bluesky', |
| 76 | link: "https://bsky.app/profile/wotaku.wiki", | 76 | link: 'https://bsky.app/profile/wotaku.wiki' |
| 77 | }, | 77 | } |
| 78 | ], | 78 | ], |
| 79 | footer: { | 79 | footer: { |
| 80 | message: `<a href="https://github.com/wotakumoe">The Wotaku Team</a> <span class="divider">|</span> <a href="https://github.com/wotakumoe/Wotaku/commit/${GIT_COMMIT}">${GIT_COMMIT.slice( | 80 | message: `<a href="https://github.com/wotakumoe">The Wotaku Team</a> <span class="divider">|</span> <a href="https://github.com/wotakumoe/Wotaku/commit/${GIT_COMMIT}">${GIT_COMMIT.slice( |
| 81 | 0, | 81 | 0, |
| 82 | 7, | 82 | 7 |
| 83 | )}</a>`, | 83 | )}</a>`, |
| 84 | copyright: "made with love and eepy energy", | 84 | copyright: 'made with love and eepy energy' |
| 85 | }, | 85 | } |
| 86 | }, | 86 | }, |
| 87 | vite: { | 87 | vite: { |
| 88 | experimental: { | ||
| 89 | enableNativePlugin: true, | ||
| 90 | }, | ||
| 91 | optimizeDeps: { | 88 | optimizeDeps: { |
| 92 | exclude: [ | 89 | exclude: [ |
| 93 | "@nolebase/vitepress-plugin-enhanced-readabilities/client", | 90 | '@nolebase/vitepress-plugin-enhanced-readabilities/client', |
| 94 | "@nolebase/vitepress-plugin-git-changelog/client", | 91 | '@nolebase/vitepress-plugin-git-changelog/client', |
| 95 | "@nolebase/vitepress-plugin-page-properties/client", | 92 | '@nolebase/vitepress-plugin-page-properties/client' |
| 96 | ], | 93 | ] |
| 97 | }, | 94 | }, |
| 98 | ssr: { | 95 | ssr: { |
| 99 | noExternal: [ | 96 | noExternal: [ |
| 100 | "@nolebase/vitepress-plugin-enhanced-readabilities", | 97 | '@nolebase/vitepress-plugin-enhanced-readabilities', |
| 101 | "@nolebase/vitepress-plugin-page-properties", | 98 | '@nolebase/vitepress-plugin-page-properties', |
| 102 | "@nolebase/vitepress-plugin-git-changelog", | 99 | '@nolebase/vitepress-plugin-git-changelog', |
| 103 | "@nolebase/ui", | 100 | '@nolebase/ui', |
| 104 | "@fmhy/components", | 101 | '@fmhy/components' |
| 105 | ], | 102 | ] |
| 106 | }, | 103 | }, |
| 107 | plugins: [ | 104 | plugins: [ |
| 108 | Devtools(), | 105 | Devtools(), |
| @@ -110,48 +107,48 @@ export const shared: UserConfig<DefaultTheme.Config> = { | |||
| 110 | PagePropertiesMarkdownSection(), | 107 | PagePropertiesMarkdownSection(), |
| 111 | GitChangelog({ | 108 | GitChangelog({ |
| 112 | maxGitLogCount: 20, | 109 | maxGitLogCount: 20, |
| 113 | repoURL: "https://github.com/wotakumoe/Wotaku", | 110 | repoURL: 'https://github.com/wotakumoe/Wotaku' |
| 114 | }), | 111 | }), |
| 115 | GitChangelogMarkdownSection({ sections: { disableContributors: true } }), | 112 | GitChangelogMarkdownSection({ sections: { disableContributors: true } }), |
| 116 | UnoCSS({ | 113 | UnoCSS({ |
| 117 | configFile: "../unocss.config.ts", | 114 | configFile: '../unocss.config.ts' |
| 118 | }), | 115 | }), |
| 119 | { | 116 | { |
| 120 | name: "custom:adjust-order", | 117 | name: 'custom:adjust-order', |
| 121 | configResolved(c) { | 118 | configResolved(c) { |
| 122 | movePlugin( | 119 | movePlugin( |
| 123 | c.plugins as unknown as Plugin[], | 120 | c.plugins as unknown as Plugin[], |
| 124 | "vitepress", | 121 | 'vitepress', |
| 125 | "before", | 122 | 'before', |
| 126 | "unocss:transformers:pre", | 123 | 'unocss:transformers:pre' |
| 127 | ); | 124 | ) |
| 128 | movePlugin( | 125 | movePlugin( |
| 129 | c.plugins as unknown as Plugin[], | 126 | c.plugins as unknown as Plugin[], |
| 130 | "custom:tooltip-loader", | 127 | 'custom:tooltip-loader', |
| 131 | "before", | 128 | 'before', |
| 132 | "vitepress", | 129 | 'vitepress' |
| 133 | ); | 130 | ) |
| 134 | }, | 131 | } |
| 135 | }, | 132 | } |
| 136 | ], | 133 | ], |
| 137 | resolve: { | 134 | resolve: { |
| 138 | alias: [ | 135 | alias: [ |
| 139 | { | 136 | { |
| 140 | find: /^.*\/VPBadge\.vue$/, | 137 | find: /^.*\/VPBadge\.vue$/, |
| 141 | replacement: fileURLToPath( | 138 | replacement: fileURLToPath( |
| 142 | new URL("../theme/components/Badge.vue", import.meta.url), | 139 | new URL('../theme/components/Badge.vue', import.meta.url) |
| 143 | ), | 140 | ) |
| 144 | }, | 141 | }, |
| 145 | { | 142 | { |
| 146 | find: /^.*VPSwitchAppearance\.vue$/, | 143 | find: /^.*VPSwitchAppearance\.vue$/, |
| 147 | replacement: fileURLToPath( | 144 | replacement: fileURLToPath( |
| 148 | new URL( | 145 | new URL( |
| 149 | "../theme/components/VPSwitchAppearance.vue", | 146 | '../theme/components/VPSwitchAppearance.vue', |
| 150 | import.meta.url, | 147 | import.meta.url |
| 151 | ), | 148 | ) |
| 152 | ), | 149 | ) |
| 153 | }, | 150 | } |
| 154 | ], | 151 | ] |
| 155 | }, | 152 | } |
| 156 | }, | 153 | } |
| 157 | }; | 154 | } |
package.json −3
| @@ -76,9 +76,6 @@ | |||
| 76 | "wrangler": "^4.40.2" | 76 | "wrangler": "^4.40.2" |
| 77 | }, | 77 | }, |
| 78 | "pnpm": { | 78 | "pnpm": { |
| 79 | "overrides": { | ||
| 80 | "vite": "npm:rolldown-vite@latest" | ||
| 81 | }, | ||
| 82 | "peerDependencyRules": { | 79 | "peerDependencyRules": { |
| 83 | "ignoreMissing": [ | 80 | "ignoreMissing": [ |
| 84 | "@algolia/client-search", | 81 | "@algolia/client-search", |