@@ -31,29 +31,72 @@ export default defineConfig({
3131 head : [
3232 [ "link" , { rel : "icon" , href : "/app_icon.png" } ] ,
3333 [ "meta" , { name : "theme-color" , content : "#334355" } ] ,
34+ // 预加载关键资源 - 优化 LCP
35+ [
36+ "link" ,
37+ {
38+ rel : "preload" ,
39+ href : "/app_icon.png" ,
40+ as : "image" ,
41+ fetchpriority : "high" ,
42+ } ,
43+ ] ,
44+ // 预连接优化 - 减少外部资源连接延迟
45+ [ "link" , { rel : "preconnect" , href : "https://api.github.com" } ] ,
46+ [ "link" , { rel : "preconnect" , href : "https://api.iconify.design" } ] ,
47+ [ "link" , { rel : "preconnect" , href : "https://umami.micyou.top" } ] ,
48+ [
49+ "link" ,
50+ { rel : "dns-prefetch" , href : "https://avatars.githubusercontent.com" } ,
51+ ] ,
3452 // 无障碍优化
3553 [ "meta" , { name : "format-detection" , content : "telephone=no" } ] ,
3654 [ "meta" , { name : "mobile-web-app-capable" , content : "yes" } ] ,
3755 [ "meta" , { name : "apple-mobile-web-app-capable" , content : "yes" } ] ,
38- [ "meta" , { name : "apple-mobile-web-app-status-bar-style" , content : "default" } ] ,
56+ [
57+ "meta" ,
58+ { name : "apple-mobile-web-app-status-bar-style" , content : "default" } ,
59+ ] ,
3960 ] ,
4061
4162 // 动态生成 OG 标签
4263 transformPageData ( pageData ) {
43- const pagePath = pageData . relativePath . replace ( / \. m d $ / , "" ) . replace ( / \/ i n d e x $ / , "/" ) ;
64+ const pagePath = pageData . relativePath
65+ . replace ( / \. m d $ / , "" )
66+ . replace ( / \/ i n d e x $ / , "/" ) ;
4467 const canonicalUrl = `https://micyou.top/${ pagePath } ` ;
4568 const ogImage = pageData . frontmatter . ogImage || "/app_icon.png" ;
4669
4770 const head : HeadConfig [ ] = [
4871 [ "meta" , { property : "og:type" , content : "website" } ] ,
4972 [ "meta" , { property : "og:title" , content : pageData . title || "MicYou" } ] ,
50- [ "meta" , { property : "og:description" , content : pageData . description || "将 Android 设备转变为 PC 的高质量麦克风" } ] ,
73+ [
74+ "meta" ,
75+ {
76+ property : "og:description" ,
77+ content :
78+ pageData . description || "将 Android 设备转变为 PC 的高质量麦克风" ,
79+ } ,
80+ ] ,
5181 [ "meta" , { property : "og:url" , content : canonicalUrl } ] ,
52- [ "meta" , { property : "og:image" , content : `https://micyou.top${ ogImage } ` } ] ,
82+ [
83+ "meta" ,
84+ { property : "og:image" , content : `https://micyou.top${ ogImage } ` } ,
85+ ] ,
5386 [ "meta" , { name : "twitter:card" , content : "summary_large_image" } ] ,
5487 [ "meta" , { name : "twitter:title" , content : pageData . title || "MicYou" } ] ,
55- [ "meta" , { name : "twitter:description" , content : pageData . description || "将 Android 设备转变为 PC 的高质量麦克风" } ] ,
56- [ "meta" , { name : "twitter:image" , content : `https://micyou.top${ ogImage } ` } ] ,
88+ [
89+ "meta" ,
90+ {
91+ name : "twitter:description" ,
92+ content :
93+ pageData . description || "将 Android 设备转变为 PC 的高质量麦克风" ,
94+ } ,
95+ ] ,
96+ [
97+ "meta" ,
98+ { name : "twitter:image" , content : `https://micyou.top${ ogImage } ` } ,
99+ ] ,
57100 [ "link" , { rel : "canonical" , href : canonicalUrl } ] ,
58101 ] ;
59102
0 commit comments