diff --git a/packages/cli/src/commands/publish-lite.ts b/packages/cli/src/commands/publish-lite.ts index 9d89c64..057ad1c 100644 --- a/packages/cli/src/commands/publish-lite.ts +++ b/packages/cli/src/commands/publish-lite.ts @@ -18,16 +18,18 @@ export async function createNote( const [, , , rkey] = uriMatch; const publishDate = new Date(post.frontmatter.publishDate).toISOString(); + const trimmedContent = post.content.trim(); + const titleMatch = trimmedContent.match(/^# (.+)$/m); + const title = titleMatch ? titleMatch[1] : post.frontmatter.title; const record: Record = { $type: LEXICON, - title: post.frontmatter.title, - content: post.content.slice(0, MAX_CONTENT), + title, + content: trimmedContent.slice(0, MAX_CONTENT), createdAt: publishDate, publishedAt: publishDate, }; - const response = await agent.com.atproto.repo.createRecord({ repo: agent.did!, collection: LEXICON, @@ -52,13 +54,15 @@ export async function updateNote( } const [, , , rkey] = uriMatch; - const publishDate = new Date(post.frontmatter.publishDate).toISOString(); + const trimmedContent = post.content.trim(); + const titleMatch = trimmedContent.match(/^# (.+)$/m); + const title = titleMatch ? titleMatch[1] : post.frontmatter.title; const record: Record = { $type: LEXICON, - title: post.frontmatter.title, - content: post.content.slice(0, MAX_CONTENT), + title, + content: trimmedContent.slice(0, MAX_CONTENT), createdAt: publishDate, publishedAt: publishDate, };