@@ -6,6 +6,9 @@ import { fileURLToPath } from 'node:url'
66import { Resvg } from '@resvg/resvg-js'
77import satori from 'satori'
88
9+ // Types
10+ import type { Frontmatter } from './frontmatter'
11+
912import { getApiNamesGrouped } from './api-names'
1013import { parseFrontmatter } from './frontmatter'
1114
@@ -47,6 +50,20 @@ function cleanTitle (raw: string): string {
4750 return raw . includes ( ' - ' ) ? raw . split ( ' - ' ) [ 0 ] : raw
4851}
4952
53+ const CATEGORY_MAP : Record < string , string > = {
54+ introduction : 'Introduction' ,
55+ guide : 'Guide' ,
56+ components : 'Components' ,
57+ composables : 'Composables' ,
58+ utilities : 'Utilities' ,
59+ api : 'API Reference' ,
60+ }
61+
62+ function inferCategory ( path : string , frontmatter : Frontmatter ) : string | undefined {
63+ if ( frontmatter . features ?. category ) return frontmatter . features . category
64+ return CATEGORY_MAP [ path . split ( '/' ) [ 1 ] ]
65+ }
66+
5067function template ( title : string , description : string , category ?: string ) {
5168 return {
5269 type : 'div' ,
@@ -111,7 +128,7 @@ function template (title: string, description: string, category?: string) {
111128 type : 'div' ,
112129 props : {
113130 style : {
114- fontSize : '56px ' ,
131+ fontSize : '76px ' ,
115132 fontWeight : 700 ,
116133 lineHeight : '1.2' ,
117134 marginBottom : '24px' ,
@@ -125,7 +142,7 @@ function template (title: string, description: string, category?: string) {
125142 type : 'div' ,
126143 props : {
127144 style : {
128- fontSize : '26px ' ,
145+ fontSize : '34px ' ,
129146 color : 'rgba(255, 255, 255, 0.7)' ,
130147 lineHeight : '1.5' ,
131148 } ,
@@ -184,11 +201,12 @@ export async function generateOgImages (): Promise<void> {
184201
185202 if ( ! frontmatter . title ) continue
186203
204+ const path = getPath ( file )
187205 files . push ( {
188- path : getPath ( file ) ,
206+ path,
189207 title : cleanTitle ( frontmatter . title ) ,
190208 description : frontmatter . description ?? '' ,
191- category : frontmatter . features ?. category ,
209+ category : inferCategory ( path , frontmatter ) ,
192210 } )
193211 }
194212
0 commit comments