Serve the pages the panel publishes
The landing was one address. It now also answers on the pages the panel publishes -- "Sobre nosotros" and the like -- at the addresses the API itself chooses: `path` and `alternates` put the default language unprefixed and every other one under its code, so `/sobre-nosotros`, `/en/about-us`, `/ca/qui-som` are the routes. `core/api.ts#contentRoute` is the single rule for that shape, and `/es/…` is deliberately not one of them, so a page has one address rather than two. Two routes share one load function, because Analog wants a `.server.ts` beside each `.page.ts`: `[slug]` for the default language, and `[locale]/[slug]` for the rest. Whether a slug exists is the API's answer, not something the route table knows, so the 404 middleware lets page-shaped addresses through and `ui/content-page.ts` sets the status itself from `ngOnInit` -- the same `injectResponse()` the landing uses for its 503, and `ngOnInit` because an input has no value in the constructor. Body HTML comes from the panel's editor and goes through Angular's sanitiser. The header shows the featured pages beside the section anchors; the footer lists them all. On a page the language switcher follows the API's `alternates`, and a language with no translation leads to the landing in that language instead of a 404. Verified: lint, 20 unit tests, build, and 6 e2e -- including a new one that a page-shaped address the API does not know answers 404 with `robots: noindex`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,7 +45,21 @@ const member = (id, name, slug, founder) => ({
|
||||
alternates: {}, path: `/equipo/${slug}`,
|
||||
});
|
||||
|
||||
const page = (id, title, slug, featured) => ({
|
||||
id, locale: 'es', title, slug, status: 'published', is_featured: featured,
|
||||
excerpt: 'Una página publicada desde el panel, con su propio título, extracto y cuerpo.',
|
||||
body: '<h2>Un apartado</h2><p>Texto de la página, tal como sale del editor del panel.</p><ul><li>Una lista</li><li>con dos elementos</li></ul>',
|
||||
meta_title: `${title} · Pireon`, meta_description: 'Descripción para buscadores.',
|
||||
published_at: '2026-01-01T00:00:00Z', updated_at: '2026-01-01T00:00:00Z',
|
||||
category: { id: 1, name: 'El colectivo', slug: 'colectivo', color: '#4f46e5', position: 1 },
|
||||
alternates: { es: `/${slug}`, en: `/en/${slug}-en`, ca: `/ca/${slug}-ca` }, path: `/${slug}`,
|
||||
});
|
||||
|
||||
const pages = [page(1, 'Sobre nosotros', 'sobre-nosotros', true), page(2, 'Contacto', 'contacto', false)];
|
||||
|
||||
const data = {
|
||||
'/public/v1/pages': pages,
|
||||
...Object.fromEntries(pages.map((p) => [`/public/v1/pages/${p.slug}`, p])),
|
||||
'/public/v1/site': {
|
||||
locales: [
|
||||
{ code: 'es', name: 'Español', flag: '🇪🇸', is_default: true },
|
||||
|
||||
Reference in New Issue
Block a user