List a person's blog posts on their page
A Blog posts section, the same cards as the Community blog, for the published and listed posts they're an author of. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f797e2c509
commit
7876e060e7
5 changed files with 45 additions and 1 deletions
|
|
@ -80,6 +80,24 @@ function shapeSummary(row, authors, body) {
|
|||
};
|
||||
}
|
||||
|
||||
/* A person's page: the published, listed posts they're an author
|
||||
of, newest first, as the same summaries the blog section shows.
|
||||
routes/people.js adds them to /people/:id. */
|
||||
export function postsBy(db, personId) {
|
||||
const rows = db
|
||||
.prepare(
|
||||
`SELECT b.* FROM blog_posts b
|
||||
JOIN blog_post_authors a ON a.post_id = b.id AND a.person_id = ?
|
||||
WHERE b.is_published = 1 AND b.is_listed = 1
|
||||
ORDER BY b.published_on IS NULL, b.published_on DESC, b.created_at DESC`,
|
||||
)
|
||||
.all(personId);
|
||||
const ids = rows.map((row) => row.id);
|
||||
const authors = loadAuthors(db, ids);
|
||||
const bodies = loadBlocks(db, "blog_post", ids, "body");
|
||||
return rows.map((row) => shapeSummary(row, authors.get(row.id) ?? [], bodies.get(row.id) ?? []));
|
||||
}
|
||||
|
||||
/* ── One post ──────────────────────────────────────────────── */
|
||||
|
||||
blog.get("/blog/:id", (c) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue