Add a blog, built from pages

A post is a page in the panel's "Blog" category, so it is written,
translated, scheduled and reviewed like any page, and the MCP server
can publish one the same way. Nothing new in the API.

- /blog (/en/blog, /ca/blog): posts newest first, with image, date and
  excerpt.
- A post shows its date and leads back to the blog; its structured data
  is a BlogPosting.
- /blog/rss.xml?lang=xx: one feed per language, announced in <head>.
- Posts stay out of the header and the footer, which links the blog
  once there is any post instead of growing with every one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pigui
2026-09-29 15:45:08 +02:00
parent 86b7485b32
commit fea60a168c
17 changed files with 656 additions and 27 deletions

View File

@@ -0,0 +1,27 @@
/**
* The blog is not a type of its own: a post is a page in the panel's "Blog"
* category, written, translated, scheduled and reviewed like any other page,
* and reachable by the MCP server the same way.
*
* That category has to exist with this slug in every language — the API
* filters by the slug in the language asked for.
*/
import type { Locale } from './api';
import type { PublicPage } from './api.types';
export const BLOG_CATEGORY: Record<Locale, string> = {
es: 'blog',
en: 'blog',
ca: 'blog',
};
export function isBlogPost(page: PublicPage, locale: Locale): boolean {
return page.category?.slug === BLOG_CATEGORY[locale];
}
/** Newest first, whatever order they arrived in. */
export function byPublication(pages: PublicPage[]): PublicPage[] {
return [...pages].sort((a, b) =>
(b.published_at ?? '').localeCompare(a.published_at ?? ''),
);
}