update pi

This commit is contained in:
2026-03-27 09:22:40 +00:00
parent d5b4042b06
commit 39e7bddb35
12 changed files with 82 additions and 65 deletions
@@ -42,9 +42,10 @@ export async function extractPDFToMarkdown(
const pdf = await getDocumentProxy(new Uint8Array(buffer));
const metadata = await pdf.getMetadata();
const info = (metadata.info ?? {}) as Record<string, unknown>;
// Extract title from metadata or URL
const metaTitle = metadata.info?.Title as string | undefined;
const metaTitle = typeof info.Title === "string" ? info.Title : undefined;
const urlTitle = extractTitleFromURL(url);
const title = metaTitle?.trim() || urlTitle;
@@ -79,8 +80,9 @@ export async function extractPDFToMarkdown(
lines.push("");
lines.push(`> Source: ${url}`);
lines.push(`> Pages: ${pdf.numPages}${truncated ? ` (extracted first ${pagesToExtract})` : ""}`);
if (metadata.info?.Author) {
lines.push(`> Author: ${metadata.info.Author}`);
const author = typeof info.Author === "string" ? info.Author : undefined;
if (author) {
lines.push(`> Author: ${author}`);
}
lines.push("");
lines.push("---");