diff --git a/packages/cli/src/lib/atproto.ts b/packages/cli/src/lib/atproto.ts index 31123f2..499d995 100644 --- a/packages/cli/src/lib/atproto.ts +++ b/packages/cli/src/lib/atproto.ts @@ -251,11 +251,14 @@ export async function createDocument( config.pathTemplate, ); const publishDate = new Date(post.frontmatter.publishDate); + const trimmedContent = post.content.trim() const textContent = getTextContent(post, config.textContentField); + const titleMatch = trimmedContent.match(/^# (.+)$/m) + const title = titleMatch ? titleMatch[1] : post.frontmatter.title const record: Record = { $type: "site.standard.document", - title: post.frontmatter.title, + title, site: config.publicationUri, path: postPath, textContent: textContent.slice(0, 10000), @@ -306,11 +309,14 @@ export async function updateDocument( config.pathTemplate, ); const publishDate = new Date(post.frontmatter.publishDate); + const trimmedContent = post.content.trim() const textContent = getTextContent(post, config.textContentField); + const titleMatch = trimmedContent.match(/^# (.+)$/m) + const title = titleMatch ? titleMatch[1] : post.frontmatter.title const record: Record = { $type: "site.standard.document", - title: post.frontmatter.title, + title, site: config.publicationUri, path: postPath, textContent: textContent.slice(0, 10000), @@ -384,9 +390,9 @@ export async function listDocuments( limit: 100, cursor, }); - + for (const record of response.data.records) { - if (!isDocumentRecord(record.value)) { + if (!isDocumentRecord(record.value)) { continue; }