/** * 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 = { 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 ?? ''), ); }