also looking at this
Long-form composer mode for the blog target
#10
7 files
+33
-8
| @@ -58,7 +58,7 @@ export class BlogService { | ||
| 58 | 58 | |
| 59 | 59 | async publishToPost( |
| 60 | 60 | post: { id: number, body: string }, |
| 61 | _content?: PublishContent, | |
| 61 | content?: PublishContent, | |
| 62 | 62 | ): Promise<CrosspostTargetResult> { |
| 63 | 63 | const targetUuid = uuid() |
| 64 | 64 | const createdAt = now() |
| @@ -79,16 +79,20 @@ export class BlogService { | ||
| 79 | 79 | .executeTakeFirstOrThrow() |
| 80 | 80 | |
| 81 | 81 | try { |
| 82 | // Explicit title (long-form composer) keeps the whole text as body; | |
| 83 | // otherwise the first line doubles as the title and is stripped. | |
| 84 | const explicitTitle = content?.title?.trim() | |
| 82 | 85 | const lines = post.body.split('\n').map(line => line.trim()) |
| 83 | const title = (lines.find(Boolean) || 'Untitled post').slice(0, 200) | |
| 86 | const title = (explicitTitle || lines.find(Boolean) || 'Untitled post').slice(0, 200) | |
| 84 | 87 | const body = post.body.trim() |
| 85 | 88 | const slug = await uniqueSlug(slugify(title)) |
| 86 | 89 | const accountId = await ensureAccount() |
| 87 | 90 | const publishedAt = now() |
| 88 | 91 | |
| 89 | // Body minus the title line — the blog theme already renders the title. | |
| 90 | 92 | const firstContentIndex = post.body.split('\n').findIndex(line => line.trim()) |
| 91 | const markdownBody = post.body.split('\n').slice(firstContentIndex + 1).join('\n').trim() || body | |
| 93 | const markdownBody = explicitTitle | |
| 94 | ? body | |
| 95 | : post.body.split('\n').slice(firstContentIndex + 1).join('\n').trim() || body | |
| 92 | 96 | |
| 93 | 97 | await mkdir(CONTENT_DIR, { recursive: true }) |
| 94 | 98 | await Bun.write(join(CONTENT_DIR, `${slug}.md`), [ |