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:
@@ -43,6 +43,16 @@ test.describe('landing', () => {
|
||||
await expect(page.locator('h1')).toContainText('no existe');
|
||||
});
|
||||
|
||||
test('answers 404 for a page the API does not have', async ({ page }) => {
|
||||
// Shaped like a content page, so the middleware lets it through and the
|
||||
// status has to come from the page component, once the API said no.
|
||||
const response = await page.goto('/en/no-such-page');
|
||||
|
||||
expect(response?.status()).toBe(404);
|
||||
await expect(page.locator('h1')).toContainText('no existe');
|
||||
await expect(page.locator('meta[name="robots"]')).toHaveAttribute('content', 'noindex');
|
||||
});
|
||||
|
||||
test('refuses an incomplete contact submission without calling the API', async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user