@@ -36,7 +36,7 @@ export async function getSatoriFonts(headerFont: FontSpecification, bodyFont: Fo
3636 name : headerFontName ,
3737 data,
3838 weight,
39- style : "normal" as const ,
39+ style : "normal" ,
4040 }
4141 } )
4242
@@ -47,10 +47,17 @@ export async function getSatoriFonts(headerFont: FontSpecification, bodyFont: Fo
4747 name : bodyFontName ,
4848 data,
4949 weight,
50- style : "normal" as const ,
50+ style : "normal" ,
5151 }
5252 } )
5353
54+ const data = await fetchTtf ( "Menlo" , 600 )
55+ if ( data ) {
56+ bodyFontPromises . push ( new Promise ( ( resolve ) => {
57+ resolve ( { name : "Menlo" , data : data , weight : 600 , style : "monospace" } )
58+ } ) )
59+ }
60+
5461 const [ headerFonts , bodyFonts ] = await Promise . all ( [
5562 Promise . all ( headerFontPromises ) ,
5663 Promise . all ( bodyFontPromises ) ,
@@ -78,6 +85,9 @@ export async function fetchTtf(
7885 if ( rawFontName === "Verdana" ) {
7986 return await fs . readFile ( path . join ( "quartz" , "redistless" , "Verdana.ttf" ) )
8087 }
88+ if ( rawFontName === "Menlo" ) {
89+ return await fs . readFile ( path . join ( "quartz" , "redistless" , "Menlo.ttf" ) )
90+ }
8191
8292 const fontName = rawFontName . replaceAll ( " " , "+" )
8393 const cacheKey = `${ fontName } -${ weight } `
@@ -201,6 +211,14 @@ export const defaultImage: SocialImageOptions["imageStructure"] = ({
201211 const bodyFont = getFontSpecificationName ( cfg . theme . typography . body )
202212 const headerFont = getFontSpecificationName ( cfg . theme . typography . header )
203213
214+ let hasRichBody = false ;
215+
216+ if ( fileData . frontmatter ?. headers ) {
217+ const keys = Object . keys ( fileData . frontmatter . headers )
218+ if ( keys . length > 0 ) hasRichBody = true ;
219+ }
220+
221+
204222 return (
205223 < div
206224 style = { {
@@ -267,7 +285,7 @@ export const defaultImage: SocialImageOptions["imageStructure"] = ({
267285 textOverflow : "ellipsis" ,
268286 } }
269287 >
270- { title }
288+ { fileData . frontmatter ?. title } | DM Ref
271289 </ h1 >
272290 </ div >
273291
@@ -291,7 +309,27 @@ export const defaultImage: SocialImageOptions["imageStructure"] = ({
291309 textOverflow : "ellipsis" ,
292310 } }
293311 >
294- { description }
312+ < div style = { {
313+ display : "flex" ,
314+ flexDirection : "column" ,
315+ } } >
316+ { hasRichBody ? Object . keys ( fileData . frontmatter ?. headers ! ) . slice ( 0 , 3 ) . map ( ( header ) => (
317+ < div key = { header } style = { {
318+ display : "flex" ,
319+ flexDirection : "row" ,
320+ flex : 1
321+ } } >
322+ < p style = { { textDecoration : "underline" , fontWeight : "bold" } } >
323+ { header } :
324+ </ p >
325+ { fileData . frontmatter ?. headers ? (
326+ < p style = { { marginLeft : "10px" , fontFamily : header === "Format" ? "Menlo" : bodyFont } } >
327+ { fileData . frontmatter . headers [ header ] [ 0 ] ?. slice ( 0 , 55 ) } { fileData . frontmatter . headers [ header ] [ 0 ] ?. length > 55 ? "..." : "" } { fileData . frontmatter ?. headers [ header ] . length > 1 ? " +" : "" }
328+ </ p >
329+ ) : "" }
330+ </ div >
331+ ) ) : description }
332+ </ div >
295333 </ p >
296334 </ div >
297335
0 commit comments