aboutsummaryrefslogtreecommitdiff
path: root/doc/docs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-02-12 11:38:41 +0800
committerLi Jin <dragon-fly@qq.com>2026-02-12 11:38:41 +0800
commit01a84cb83973b1dbbcc0cbbc6835ea3f3ec755e3 (patch)
treefc86e3ffc0becd8f0b1176512cf36cbd212df5a5 /doc/docs
parent5391e4112e513b8052bc700bc0f062aebdfb8098 (diff)
downloadyuescript-01a84cb83973b1dbbcc0cbbc6835ea3f3ec755e3.tar.gz
yuescript-01a84cb83973b1dbbcc0cbbc6835ea3f3ec755e3.tar.bz2
yuescript-01a84cb83973b1dbbcc0cbbc6835ea3f3ec755e3.zip
Try a fix. [skip CI]
Diffstat (limited to 'doc/docs')
-rw-r--r--doc/docs/.vitepress/config.mts30
-rw-r--r--doc/docs/.vitepress/theme/index.ts25
2 files changed, 46 insertions, 9 deletions
diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts
index b458501..635d087 100644
--- a/doc/docs/.vitepress/config.mts
+++ b/doc/docs/.vitepress/config.mts
@@ -21,6 +21,15 @@ const yuescriptLanguage = {
21 aliases: ["yue"], 21 aliases: ["yue"],
22}; 22};
23 23
24const docsBase = process.env.DOCS_BASE ?? "/";
25
26function withBase(path: string) {
27 if (!path.startsWith("/") || docsBase === "/") {
28 return path;
29 }
30 return `${docsBase.replace(/\/$/, "")}${path}`;
31}
32
24const sidebarText = { 33const sidebarText = {
25 de: { 34 de: {
26 introduction: "Einführung", 35 introduction: "Einführung",
@@ -415,7 +424,7 @@ function createSidebar(basePath: string, locale: SidebarLocale) {
415export default defineConfig({ 424export default defineConfig({
416 title: "YueScript", 425 title: "YueScript",
417 description: "A language that compiles to Lua", 426 description: "A language that compiles to Lua",
418 base: "/", 427 base: docsBase,
419 head: [ 428 head: [
420 ["meta", { name: "theme-color", content: "#b4ac8f" }], 429 ["meta", { name: "theme-color", content: "#b4ac8f" }],
421 ["meta", { name: "apple-mobile-web-app-capable", content: "yes" }], 430 ["meta", { name: "apple-mobile-web-app-capable", content: "yes" }],
@@ -432,10 +441,13 @@ export default defineConfig({
432 }, 441 },
433 ], 442 ],
434 ["meta", { property: "og:type", content: "website" }], 443 ["meta", { property: "og:type", content: "website" }],
435 ["meta", { property: "og:image", content: "/image/yuescript.png" }], 444 ["meta", { property: "og:image", content: withBase("/image/yuescript.png") }],
436 [ 445 [
437 "meta", 446 "meta",
438 { property: "og:image:secure_url", content: "/image/yuescript.png" }, 447 {
448 property: "og:image:secure_url",
449 content: withBase("/image/yuescript.png"),
450 },
439 ], 451 ],
440 ["meta", { property: "og:image:type", content: "image/png" }], 452 ["meta", { property: "og:image:type", content: "image/png" }],
441 ["meta", { property: "og:image:width", content: "1200" }], 453 ["meta", { property: "og:image:width", content: "1200" }],
@@ -444,7 +456,7 @@ export default defineConfig({
444 "link", 456 "link",
445 { 457 {
446 rel: "icon", 458 rel: "icon",
447 href: "/image/favicon/favicon-16x16.png", 459 href: withBase("/image/favicon/favicon-16x16.png"),
448 sizes: "16x16", 460 sizes: "16x16",
449 type: "image/png", 461 type: "image/png",
450 }, 462 },
@@ -453,7 +465,7 @@ export default defineConfig({
453 "link", 465 "link",
454 { 466 {
455 rel: "icon", 467 rel: "icon",
456 href: "/image/favicon/favicon-32x32.png", 468 href: withBase("/image/favicon/favicon-32x32.png"),
457 sizes: "32x32", 469 sizes: "32x32",
458 type: "image/png", 470 type: "image/png",
459 }, 471 },
@@ -462,7 +474,7 @@ export default defineConfig({
462 "link", 474 "link",
463 { 475 {
464 rel: "apple-touch-icon", 476 rel: "apple-touch-icon",
465 href: "/image/favicon/apple-touch-icon.png", 477 href: withBase("/image/favicon/apple-touch-icon.png"),
466 sizes: "180x180", 478 sizes: "180x180",
467 type: "image/png", 479 type: "image/png",
468 }, 480 },
@@ -471,7 +483,7 @@ export default defineConfig({
471 "link", 483 "link",
472 { 484 {
473 rel: "android-chrome", 485 rel: "android-chrome",
474 href: "/image/favicon/android-chrome-192x192.png", 486 href: withBase("/image/favicon/android-chrome-192x192.png"),
475 sizes: "192x192", 487 sizes: "192x192",
476 type: "image/png", 488 type: "image/png",
477 }, 489 },
@@ -480,7 +492,7 @@ export default defineConfig({
480 "link", 492 "link",
481 { 493 {
482 rel: "android-chrome", 494 rel: "android-chrome",
483 href: "/image/favicon/android-chrome-512x512.png", 495 href: withBase("/image/favicon/android-chrome-512x512.png"),
484 sizes: "512x512", 496 sizes: "512x512",
485 type: "image/png", 497 type: "image/png",
486 }, 498 },
@@ -505,7 +517,7 @@ export default defineConfig({
505 window.dispatchEvent(new Event('yue:ready')); 517 window.dispatchEvent(new Event('yue:ready'));
506 } 518 }
507 var s = document.createElement('script'); 519 var s = document.createElement('script');
508 s.src = '/js/yuescript.js'; 520 s.src = '${withBase("/js/yuescript.js")}';
509 s.async = true; 521 s.async = true;
510 document.head.appendChild(s); 522 document.head.appendChild(s);
511})();`, 523})();`,
diff --git a/doc/docs/.vitepress/theme/index.ts b/doc/docs/.vitepress/theme/index.ts
index 70145d5..7e9882e 100644
--- a/doc/docs/.vitepress/theme/index.ts
+++ b/doc/docs/.vitepress/theme/index.ts
@@ -12,6 +12,19 @@ import YueCompiler from "./components/YueCompiler.vue";
12// @ts-ignore 12// @ts-ignore
13import YueDisplay from "./components/YueDisplay.vue"; 13import YueDisplay from "./components/YueDisplay.vue";
14 14
15function applyShikiInlineColorFallback() {
16 if (typeof document === "undefined") return;
17 const isDark = document.documentElement.classList.contains("dark");
18 const varName = isDark ? "--shiki-dark" : "--shiki-light";
19 const spans = document.querySelectorAll<HTMLElement>(".vp-code span");
20 spans.forEach((span) => {
21 const color = span.style.getPropertyValue(varName).trim();
22 if (color) {
23 span.style.color = color;
24 }
25 });
26}
27
15const theme: Theme = { 28const theme: Theme = {
16 extends: DefaultTheme, 29 extends: DefaultTheme,
17 Layout: () => 30 Layout: () =>
@@ -22,6 +35,18 @@ const theme: Theme = {
22 app.component("CompilerModal", CompilerModal); 35 app.component("CompilerModal", CompilerModal);
23 app.component("YueCompiler", YueCompiler); 36 app.component("YueCompiler", YueCompiler);
24 app.component("YueDisplay", YueDisplay); 37 app.component("YueDisplay", YueDisplay);
38
39 if (typeof window !== "undefined") {
40 const run = () => requestAnimationFrame(applyShikiInlineColorFallback);
41 window.addEventListener("DOMContentLoaded", run, { once: true });
42 window.addEventListener("load", run, { once: true });
43
44 const observer = new MutationObserver(run);
45 observer.observe(document.documentElement, {
46 attributes: true,
47 attributeFilter: ["class"],
48 });
49 }
25 }, 50 },
26}; 51};
27 52