@@ -243,7 +243,9 @@ export const fetchDocs = createServerFn({ method: 'GET' })
243243 }
244244
245245 const frontMatter = extractFrontMatter ( file )
246- const description = removeMarkdown ( frontMatter . excerpt ?? '' )
246+ const description =
247+ frontMatter . userDescription ?? removeMarkdown ( frontMatter . excerpt ?? '' )
248+ const keywords = extractFrontMatterKeywords ( frontMatter . data . keywords )
247249 const { contentRsc, headings } = await renderMarkdownToRsc (
248250 frontMatter . content ,
249251 )
@@ -255,6 +257,7 @@ export const fetchDocs = createServerFn({ method: 'GET' })
255257 contentRsc,
256258 title : frontMatter . data ?. title ?? 'Content temporarily unavailable' ,
257259 description,
260+ keywords,
258261 frameworks : extractFrameworksFromMarkdown ( frontMatter . content ) ,
259262 filePath,
260263 headings,
@@ -270,6 +273,7 @@ export const fetchDocsPage = createServerFn({ method: 'GET' })
270273 return {
271274 contentRsc : doc . contentRsc ,
272275 description : doc . description ,
276+ keywords : doc . keywords ,
273277 filePath : doc . filePath ,
274278 frontmatter : doc . frontmatter ,
275279 frameworks : doc . frameworks ,
@@ -278,6 +282,24 @@ export const fetchDocsPage = createServerFn({ method: 'GET' })
278282 }
279283 } )
280284
285+ function extractFrontMatterKeywords ( value : unknown ) : string | undefined {
286+ if ( Array . isArray ( value ) ) {
287+ const normalized = value
288+ . filter ( ( item ) : item is string => typeof item === 'string' )
289+ . map ( ( item ) => item . trim ( ) )
290+ . filter ( ( item ) => item . length > 0 )
291+
292+ return normalized . length > 0 ? normalized . join ( ', ' ) : undefined
293+ }
294+
295+ if ( typeof value === 'string' ) {
296+ const trimmed = value . trim ( )
297+ return trimmed . length > 0 ? trimmed : undefined
298+ }
299+
300+ return undefined
301+ }
302+
281303export const fetchFile = createServerFn ( { method : 'GET' } )
282304 . inputValidator ( repoFileInput )
283305 . handler ( async ( { data } : { data : RepoFileRequest } ) => {
0 commit comments