@@ -226,19 +226,32 @@ export default defineConfig({
226
226
const coverImage = await ensureLocalImage ( pageData . frontmatter . image , "cover" , {
227
227
baseDestLocation : imageDir . split ( "/" )
228
228
} ) ;
229
- head . push ( [ "meta" , { property : "og:image" , content : resolveHref ( coverImage . urlPath . absolute , true ) } ] ) ;
229
+ const imageUrl = resolveHref ( coverImage . urlPath . absolute , true ) ;
230
+ head . push ( [ "meta" , { property : "og:image" , content : imageUrl } ] ) ;
231
+ head . push ( [ "meta" , { property : "twitter:image" , content : imageUrl } ] ) ;
232
+ head . push ( [ "meta" , { property : "twitter:card" , content : "summary_large_image" } ] ) ;
230
233
} else if ( typeof pageData . frontmatter . image === "object" ) {
231
234
const coverImage = typeof pageData . frontmatter . image . url === "string"
232
235
? await ensureLocalImage ( pageData . frontmatter . image . url , "cover" , {
233
236
baseDestLocation : imageDir . split ( "/" )
234
237
} )
235
238
: undefined ;
236
239
237
- if ( typeof pageData . frontmatter . image . url === "string" )
240
+ if ( typeof pageData . frontmatter . image . url === "string" ) {
241
+ const imageUrl = resolveHref ( coverImage ?. urlPath . absolute ?? pageData . frontmatter . image . url , true ) ;
238
242
head . push ( [ "meta" , {
239
243
property : "og:image" ,
240
- content : resolveHref ( coverImage ?. urlPath . absolute ?? pageData . frontmatter . image . url , true )
244
+ content : imageUrl
241
245
} ] ) ;
246
+ head . push ( [ "meta" , {
247
+ property : "twitter:image" ,
248
+ content : imageUrl
249
+ } ] ) ;
250
+ head . push ( [ "meta" , {
251
+ property : "twitter:card" ,
252
+ content : "summary_large_image"
253
+ } ] ) ;
254
+ }
242
255
243
256
if ( pageData . frontmatter . image . width != null )
244
257
head . push ( [ "meta" , {
@@ -691,10 +704,17 @@ export default defineConfig({
691
704
"/_blog/" : {
692
705
text : "Blog" ,
693
706
link : "/blog/" ,
694
- items : blogPosts . map ( ( post ) => ( {
695
- text : post . frontmatter . title ,
696
- link : post . url
697
- } ) )
707
+ items : blogPosts
708
+ . filter ( ( post ) => {
709
+ const hasCoverImage = typeof post . frontmatter ?. image === "string" ||
710
+ typeof post . frontmatter ?. image ?. url === "string" ;
711
+
712
+ return ! hasCoverImage ;
713
+ } )
714
+ . map ( ( post ) => ( {
715
+ text : post . frontmatter . title ,
716
+ link : post . url
717
+ } ) )
698
718
}
699
719
}
700
720
}
0 commit comments