feat(theme): replace with twemojis
This commit is contained in:
parent
4cead6f935
commit
0e69461b59
4
.github/replace.py
vendored
4
.github/replace.py
vendored
@ -53,6 +53,10 @@ def general(text: str):
|
|||||||
text = re.sub("## ▷", "###", text)
|
text = re.sub("## ▷", "###", text)
|
||||||
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(
|
text = re.sub(
|
||||||
r"^\*\*Note\*\* - (.+)$", r":::tip\n\1\n:::", text, flags=re.MULTILINE
|
r"^\*\*Note\*\* - (.+)$", r":::tip\n\1\n:::", text, flags=re.MULTILINE
|
||||||
)
|
)
|
||||||
|
@ -5,6 +5,7 @@ import { commitRef, feedback, meta, search, sidebar, socialLinks } from "./const
|
|||||||
import { generateImages, generateMeta, generateFeed } from "./hooks";
|
import { generateImages, generateMeta, generateFeed } from "./hooks";
|
||||||
import { toggleStarredPlugin } from "./markdown/toggleStarred";
|
import { toggleStarredPlugin } from "./markdown/toggleStarred";
|
||||||
import { base64DecodePlugin } from "./markdown/base64";
|
import { base64DecodePlugin } from "./markdown/base64";
|
||||||
|
import { movePlugin, emojiRender, defs } from "./markdown/emoji";
|
||||||
|
|
||||||
const baseUrl = process.env.GITHUB_ACTIONS ? "/FMHYedit" : "/";
|
const baseUrl = process.env.GITHUB_ACTIONS ? "/FMHYedit" : "/";
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@ -41,10 +42,17 @@ export default defineConfig({
|
|||||||
.finally(() => consola.success("Success!"));
|
.finally(() => consola.success("Success!"));
|
||||||
},
|
},
|
||||||
vite: {
|
vite: {
|
||||||
|
optimizeDeps: { exclude: ["workbox-window"] },
|
||||||
plugins: [
|
plugins: [
|
||||||
UnoCSS({
|
UnoCSS({
|
||||||
configFile: "../unocss.config.ts",
|
configFile: "../unocss.config.ts",
|
||||||
}),
|
}),
|
||||||
|
{
|
||||||
|
name: "custom:adjust-order",
|
||||||
|
configResolved(c) {
|
||||||
|
movePlugin(c.plugins as any, "vitepress", "before", "unocss:transformers:pre");
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
build: {
|
build: {
|
||||||
// Shut the fuck up
|
// Shut the fuck up
|
||||||
@ -52,7 +60,9 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
markdown: {
|
markdown: {
|
||||||
|
emoji: { defs },
|
||||||
config(md) {
|
config(md) {
|
||||||
|
md.use(emojiRender);
|
||||||
md.use(toggleStarredPlugin);
|
md.use(toggleStarredPlugin);
|
||||||
md.use(base64DecodePlugin);
|
md.use(base64DecodePlugin);
|
||||||
},
|
},
|
||||||
|
39
.vitepress/markdown/emoji.ts
Normal file
39
.vitepress/markdown/emoji.ts
Normal file
@ -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 `<span class="i-twemoji-${tokens[idx].markup}"></span>`;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"extends": "./.nitro/types/tsconfig.json",
|
"extends": "./.nitro/types/tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"verbatimModuleSyntax": true
|
"verbatimModuleSyntax": true,
|
||||||
}
|
},
|
||||||
|
"include": ["./.vitepress/"],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user