this repo has no description

fix: extract title from markdown heading and trim content in litenote records

authored by

Julien Calixte and committed by
Julien Calixte
79fae718 7f3dd598

+10 -6
+10 -6
packages/cli/src/commands/publish-lite.ts
··· 18 18 19 19 const [, , , rkey] = uriMatch; 20 20 const publishDate = new Date(post.frontmatter.publishDate).toISOString(); 21 + const trimmedContent = post.content.trim(); 22 + const titleMatch = trimmedContent.match(/^# (.+)$/m); 23 + const title = titleMatch ? titleMatch[1] : post.frontmatter.title; 21 24 22 25 const record: Record<string, unknown> = { 23 26 $type: LEXICON, 24 - title: post.frontmatter.title, 25 - content: post.content.slice(0, MAX_CONTENT), 27 + title, 28 + content: trimmedContent.slice(0, MAX_CONTENT), 26 29 createdAt: publishDate, 27 30 publishedAt: publishDate, 28 31 }; 29 - 30 32 31 33 const response = await agent.com.atproto.repo.createRecord({ 32 34 repo: agent.did!, ··· 52 54 } 53 55 54 56 const [, , , rkey] = uriMatch; 55 - 56 57 const publishDate = new Date(post.frontmatter.publishDate).toISOString(); 58 + const trimmedContent = post.content.trim(); 59 + const titleMatch = trimmedContent.match(/^# (.+)$/m); 60 + const title = titleMatch ? titleMatch[1] : post.frontmatter.title; 57 61 58 62 const record: Record<string, unknown> = { 59 63 $type: LEXICON, 60 - title: post.frontmatter.title, 61 - content: post.content.slice(0, MAX_CONTENT), 64 + title, 65 + content: trimmedContent.slice(0, MAX_CONTENT), 62 66 createdAt: publishDate, 63 67 publishedAt: publishDate, 64 68 };