@@ -226,19 +226,32 @@ export default defineConfig({
226226 const coverImage = await ensureLocalImage ( pageData . frontmatter . image , "cover" , {
227227 baseDestLocation : imageDir . split ( "/" )
228228 } ) ;
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" } ] ) ;
230233 } else if ( typeof pageData . frontmatter . image === "object" ) {
231234 const coverImage = typeof pageData . frontmatter . image . url === "string"
232235 ? await ensureLocalImage ( pageData . frontmatter . image . url , "cover" , {
233236 baseDestLocation : imageDir . split ( "/" )
234237 } )
235238 : undefined ;
236239
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 ) ;
238242 head . push ( [ "meta" , {
239243 property : "og:image" ,
240- content : resolveHref ( coverImage ?. urlPath . absolute ?? pageData . frontmatter . image . url , true )
244+ content : imageUrl
241245 } ] ) ;
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+ }
242255
243256 if ( pageData . frontmatter . image . width != null )
244257 head . push ( [ "meta" , {
@@ -691,10 +704,17 @@ export default defineConfig({
691704 "/_blog/" : {
692705 text : "Blog" ,
693706 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+ } ) )
698718 }
699719 }
700720 }
0 commit comments