diff --git a/.github/replace.py b/.github/replace.py index 0e9870205..0e9bc9091 100644 --- a/.github/replace.py +++ b/.github/replace.py @@ -53,6 +53,10 @@ def general(text: str): text = re.sub("## ▷", "###", text) text = re.sub("####", "###", text) + text = re.sub("⭐", ":star:", text) + text = re.sub("🌐", ":globe-with-meridians: ", text) + text = re.sub("↪️ ", ":repeat-button: ", text) + text = re.sub( r"^\*\*Note\*\* - (.+)$", r":::tip\n\1\n:::", text, flags=re.MULTILINE ) diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 0027bca79..e62e0b795 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -5,6 +5,7 @@ import { commitRef, feedback, meta, search, sidebar, socialLinks } from "./const import { generateImages, generateMeta, generateFeed } from "./hooks"; import { toggleStarredPlugin } from "./markdown/toggleStarred"; import { base64DecodePlugin } from "./markdown/base64"; +import { movePlugin, emojiRender, defs } from "./markdown/emoji"; const baseUrl = process.env.GITHUB_ACTIONS ? "/FMHYedit" : "/"; export default defineConfig({ @@ -41,10 +42,17 @@ export default defineConfig({ .finally(() => consola.success("Success!")); }, vite: { + optimizeDeps: { exclude: ["workbox-window"] }, plugins: [ UnoCSS({ configFile: "../unocss.config.ts", }), + { + name: "custom:adjust-order", + configResolved(c) { + movePlugin(c.plugins as any, "vitepress", "before", "unocss:transformers:pre"); + }, + }, ], build: { // Shut the fuck up @@ -52,7 +60,9 @@ export default defineConfig({ }, }, markdown: { + emoji: { defs }, config(md) { + md.use(emojiRender); md.use(toggleStarredPlugin); md.use(base64DecodePlugin); }, diff --git a/.vitepress/markdown/emoji.ts b/.vitepress/markdown/emoji.ts new file mode 100644 index 000000000..1e0937fff --- /dev/null +++ b/.vitepress/markdown/emoji.ts @@ -0,0 +1,39 @@ +import { icons as twemoji } from "@iconify-json/twemoji"; +import type { MarkdownRenderer } from "vitepress"; + +export const defs = { + ...Object.fromEntries( + Object.entries(twemoji.icons).map(([key]) => { + return [key, ""]; + }), + ), +}; + +export function emojiRender(md: MarkdownRenderer) { + md.renderer.rules.emoji = (tokens, idx) => { + return ``; + }; +} + +export function movePlugin( + plugins: { name: string }[], + pluginAName: string, + order: "before" | "after", + pluginBName: string, +) { + const pluginBIndex = plugins.findIndex((p) => p.name === pluginBName); + if (pluginBIndex === -1) return; + + const pluginAIndex = plugins.findIndex((p) => p.name === pluginAName); + if (pluginAIndex === -1) return; + + if (order === "before" && pluginAIndex > pluginBIndex) { + const pluginA = plugins.splice(pluginAIndex, 1)[0]; + plugins.splice(pluginBIndex, 0, pluginA); + } + + if (order === "after" && pluginAIndex < pluginBIndex) { + const pluginA = plugins.splice(pluginAIndex, 1)[0]; + plugins.splice(pluginBIndex, 0, pluginA); + } +} diff --git a/tsconfig.json b/tsconfig.json index 79a477195..e5fe210d5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "./.nitro/types/tsconfig.json", "compilerOptions": { - "verbatimModuleSyntax": true - } + "verbatimModuleSyntax": true, + }, + "include": ["./.vitepress/"], }