NGU-Web/server/src/admin-schema/blog.js
Zaldimmar 92e7938b64 Give blog posts an optional table of contents
Blog posts -> Show contents (migration 043, off by default): with two
or more headings, the post's headings sit in a sticky column beside
it with the one being read lit (an IntersectionObserver, not a scroll
listener), and fold out at the top on phones. Content-block headings
now carry anchor ids, so a link can point at one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 09:21:48 -05:00

93 lines
2.4 KiB
JavaScript

import { text, url, int, bool, date, featuredCardsChild, blocksChild } from "./columns.js";
/* ── Blog (031_blog.sql) ─────────────────────────────────────────
Posts of our own, with a content-block body and people as
authors, and the Community page's blog section, a singleton like
the front page. The section's community posts are featured cards
owned by 'community_page'. ─────────────────────────────────── */
export const blogPosts = {
key: "blog_posts",
table: "blog_posts",
idColumn: "id",
idKind: "slug",
concurrency: "updated_at",
list: {
columns: ["id", "title", "published_on", "tags", "is_published", "is_listed", "updated_at"],
filters: ["is_published", "is_listed"],
search: ["title", "id", "tags"],
order: "published_on IS NULL, published_on DESC, title",
},
columns: [
text("title", { required: true }),
text("excerpt"),
text("cover_image"),
text("cover_alt"),
bool("show_contents"),
date("published_on"),
text("tags"),
text("guest_author"),
text("guest_photo"),
bool("is_published"),
bool("is_listed"),
],
children: [
{
key: "authors",
table: "blog_post_authors",
owner: { column: "post_id" },
order: "sort_order",
columns: [text("person_id", { required: true })],
},
blocksChild("blog_post"),
],
};
export const communityPage = {
key: "community_page",
table: "community_page",
idColumn: "id",
idKind: "slug",
singleton: "community",
concurrency: "updated_at",
list: {
columns: ["id", "blog_title", "updated_at"],
filters: [],
search: [],
order: "id",
},
columns: [
text("blog_title"),
text("blog_blurb"),
text("internal_title"),
int("internal_slots"),
text("external_title"),
int("external_slots"),
url("external_url"),
text("external_label"),
],
children: [
{
key: "pinned_posts",
table: "community_page_pinned_posts",
owner: { column: "page_id" },
order: "sort_order",
columns: [text("post_id", { required: true })],
},
featuredCardsChild("community_page"),
{
key: "feeds",
table: "community_page_feeds",
owner: { column: "page_id" },
order: "sort_order",
columns: [url("url", { required: true }), text("label")],
},
],
};