Skip to content

Commit 3cc069b

Browse files
Kaleidosiumpigpigyyy
authored andcommitted
Clickable hero image on homepage to navigate to the mascot reference page.
1 parent 760505c commit 3cc069b

6 files changed

Lines changed: 38 additions & 3 deletions

File tree

doc/docs/.vitepress/theme/index.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import DefaultTheme from "vitepress/theme";
22
import type { Theme } from "vitepress";
33
import { h } from "vue";
4+
import { useData, withBase } from "vitepress";
45
import "./custom.css";
56

67
// @ts-ignore
@@ -14,10 +15,39 @@ import YueDisplay from "./components/YueDisplay.vue";
1415

1516
const theme: Theme = {
1617
extends: DefaultTheme,
17-
Layout: () =>
18-
h(DefaultTheme.Layout, null, {
18+
Layout: () => {
19+
const { frontmatter } = useData();
20+
21+
return h(DefaultTheme.Layout, null, {
1922
"layout-bottom": () => [h(HomeFooter), h(CompilerModal)],
20-
}),
23+
"home-hero-image": () => {
24+
const fm = frontmatter.value;
25+
if (fm?.hero?.image?.src) {
26+
const img = h("img", {
27+
src: withBase(fm.hero.image.src),
28+
alt: fm.hero.image.alt || "",
29+
class: "VPImage",
30+
style: "max-width: 100%; max-height: 100%; object-fit: contain;",
31+
});
32+
33+
if (fm.hero.image.link) {
34+
return h(
35+
"a",
36+
{
37+
href: withBase(fm.hero.image.link),
38+
class: "image-src",
39+
style: "display: flex; justify-content: center; align-items: center;",
40+
},
41+
[img]
42+
);
43+
}
44+
45+
return h("div", { class: "image-src", style: "display: flex; justify-content: center; align-items: center;" }, [img]);
46+
}
47+
return null;
48+
},
49+
});
50+
},
2151
enhanceApp({ app }) {
2252
app.component("CompilerModal", CompilerModal);
2353
app.component("YueCompiler", YueCompiler);

doc/docs/de/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ hero:
66
image:
77
src: /image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png
88
alt: YueScript
9+
link: /de/doc/reference/mascot
910
actions:
1011
- theme: brand
1112
text: Schnellstart →

doc/docs/id-id/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ hero:
66
image:
77
src: /image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png
88
alt: YueScript
9+
link: /id-id/doc/reference/mascot
910
actions:
1011
- theme: brand
1112
text: Mulai Cepat →

doc/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ hero:
66
image:
77
src: /image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png
88
alt: YueScript
9+
link: /doc/reference/mascot
910
actions:
1011
- theme: brand
1112
text: Quick Start →

doc/docs/pt-br/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ hero:
66
image:
77
src: /image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png
88
alt: YueScript
9+
link: /pt-br/doc/reference/mascot
910
actions:
1011
- theme: brand
1112
text: Início rápido →

doc/docs/zh/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ hero:
66
image:
77
src: /image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png
88
alt: 月之脚本
9+
link: /zh/doc/reference/mascot
910
actions:
1011
- theme: brand
1112
text: 快速上手 →

0 commit comments

Comments
 (0)