11import DefaultTheme from "vitepress/theme" ;
22import type { Theme } from "vitepress" ;
33import { h } from "vue" ;
4+ import { useData , withBase } from "vitepress" ;
45import "./custom.css" ;
56
67// @ts -ignore
@@ -14,10 +15,39 @@ import YueDisplay from "./components/YueDisplay.vue";
1415
1516const 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 ) ;
0 commit comments