Skip to content

Commit 7b9043b

Browse files
Copilothotlong
andcommitted
Address code review: add error handling for getLLMText and clarify includeProcessedMarkdown comment
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 95480e9 commit 7b9043b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/site/lib/source.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ export function getPageImage(page: InferPageType<typeof source>) {
2828
}
2929

3030
export async function getLLMText(page: InferPageType<typeof source>) {
31-
const processed = await page.data.getText('processed');
31+
try {
32+
const processed = await page.data.getText('processed');
3233

33-
return `# ${page.data.title}
34+
return `# ${page.data.title}
3435
3536
${processed}`;
37+
} catch {
38+
return `# ${page.data.title}
39+
40+
${page.data.description ?? ''}`;
41+
}
3642
}
3743

packages/site/source.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const docs = defineDocs({
3535
docs: {
3636
schema: frontmatterSchema,
3737
postprocess: {
38+
// Required for LLM text generation (getLLMText in lib/source.ts)
3839
includeProcessedMarkdown: true,
3940
},
4041
},

0 commit comments

Comments
 (0)