this repo has no description

fix: get title from markdown if not found in frontmatter

authored by

Julien Calixte and committed by
Julien Calixte
b5fe8164 b35d74cf

+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 // Fetch existing record to preserve PDS-side fields (e.g. bskyPostRef) 312 318 const existingResponse = await agent.com.atproto.repo.getRecord({ ··· 319 325 const record: Record<string, unknown> = { 320 326 ...existingRecord, 321 327 $type: "site.standard.document", 322 - title: post.frontmatter.title, 328 + title, 323 329 site: config.publicationUri, 324 330 path: postPath, 325 331 textContent: textContent.slice(0, 10000), ··· 393 399 limit: 100, 394 400 cursor, 395 401 }); 396 - 402 + 397 403 for (const record of response.data.records) { 398 - if (!isDocumentRecord(record.value)) { 404 + if (!isDocumentRecord(record.value)) { 399 405 continue; 400 406 } 401 407