Request details, Drive folders, image folders, clip tool to Drive (v1.9.12 to v1.9.14-content-display) #16
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) => {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
import { Hono } from "hono";
|
||||
|
||||
import { asBool, json, loadOwned, marks, paragraphs, splitLinks } from "../shape.js";
|
||||
import { postsBy } from "./blog.js";
|
||||
|
||||
const people = new Hono();
|
||||
|
||||
|
|
@ -284,6 +285,8 @@ people.get("/people/:id", (c) => {
|
|||
roles,
|
||||
events: [...byEvent.values()],
|
||||
awards,
|
||||
// Blog posts they wrote (published and listed).
|
||||
posts: postsBy(db, id),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
* hrefs.ts has already logged the component that produced it.
|
||||
*/
|
||||
|
||||
import type { BlogPostSummary } from './useBlog.ts'
|
||||
import { detailPath } from './hrefs.ts'
|
||||
import { useRecord, type Resource } from './useRecord.ts'
|
||||
import type { EventType } from './eventTypes.ts'
|
||||
|
|
@ -356,6 +357,8 @@ export type PersonRecord = {
|
|||
roles: PersonRole[]
|
||||
events: PersonEvent[]
|
||||
awards: PersonAward[]
|
||||
/** Blog posts they wrote, newest first. */
|
||||
posts: BlogPostSummary[]
|
||||
}
|
||||
|
||||
export const usePerson = (id?: string): Resource<PersonRecord> =>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import PageShell, { type ShellSection } from '../components/PageShell.tsx'
|
|||
import PageState from '../components/PageState.tsx'
|
||||
import PlatformIcon from '../components/PlatformIcon.tsx'
|
||||
import ContentBlocks from '../components/ContentBlocks.tsx'
|
||||
import { PostCard } from './sections/CommunityBlog.tsx'
|
||||
import {
|
||||
usePerson,
|
||||
type PersonEvent,
|
||||
|
|
@ -190,6 +191,24 @@ export default function PersonDetail() {
|
|||
})
|
||||
}
|
||||
|
||||
if (person.posts?.length > 0) {
|
||||
sections.push({
|
||||
id: 'posts',
|
||||
title: 'Blog posts',
|
||||
accent,
|
||||
background: BACKGROUNDS[sections.length % 2],
|
||||
content: (
|
||||
<div className="max-w-6xl mx-auto px-6">
|
||||
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{person.posts.map((post) => (
|
||||
<PostCard key={post.id} post={post} accent={accent} />
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<PageShell title={person.name} intro={person.tagline ?? undefined} sections={sections} />
|
||||
)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ const DEFAULTS = {
|
|||
|
||||
const EXCERPT_CHARS = 180
|
||||
|
||||
function PostCard({ post, accent }: { post: BlogPostSummary; accent: string }) {
|
||||
/* One post as a card; person pages list their posts with it too. */
|
||||
export function PostCard({ post, accent }: { post: BlogPostSummary; accent: string }) {
|
||||
const cover = useSmallImage(mediaUrl(post.cover_image))
|
||||
const date = postDate(post.published_on)
|
||||
const authors = post.authors.map((author) => author.name).join(', ')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue