A CLI for publishing standard.site documents to ATProto

fix: get title from markdown if not found in frontmatter

+10 -4
+10 -4
packages/cli/src/lib/atproto.ts
··· 251 251 config.pathTemplate, 252 252 ); 253 253 const publishDate = new Date(post.frontmatter.publishDate); 254 + const trimmedContent = post.content.trim() 254 255 const textContent = getTextContent(post, config.textContentField); 256 + const titleMatch = trimmedContent.match(/^# (.+)$/m) 257 + const title = titleMatch ? titleMatch[1] : post.frontmatter.title 255 258 256 259 const record: Record<string, unknown> = { 257 260 $type: "site.standard.document", 258 - title: post.frontmatter.title, 261 + title, 259 262 site: config.publicationUri, 260 263 path: postPath, 261 264 textContent: textContent.slice(0, 10000), ··· 306 309 config.pathTemplate, 307 310 ); 308 311 const publishDate = new Date(post.frontmatter.publishDate); 312 + const trimmedContent = post.content.trim() 309 313 const textContent = getTextContent(post, config.textContentField); 314 + const titleMatch = trimmedContent.match(/^# (.+)$/m) 315 + const title = titleMatch ? titleMatch[1] : post.frontmatter.title 310 316 311 317 const record: Record<string, unknown> = { 312 318 $type: "site.standard.document", 313 - title: post.frontmatter.title, 319 + title, 314 320 site: config.publicationUri, 315 321 path: postPath, 316 322 textContent: textContent.slice(0, 10000), ··· 384 390 limit: 100, 385 391 cursor, 386 392 }); 387 - 393 + 388 394 for (const record of response.data.records) { 389 - if (!isDocumentRecord(record.value)) { 395 + if (!isDocumentRecord(record.value)) { 390 396 continue; 391 397 } 392 398