Tell search engines and link previews what each page is

- /sitemap.xml, from the API's /slugs plus the landing and listings:
  every address in every language, with hreflang and x-default. A 503
  when the API is down, rather than a sitemap missing half the site.
- /robots.txt, naming the sitemap on whatever domain this is served on.
- Slugs renamed in the panel now redirect. The API has always kept the
  old address the moment one changed; middleware/redirects.ts answers
  it with a 301, from a list kept for a minute and through outages.
- og:url, og:image (the record's own picture, the logo otherwise) and
  schema.org JSON-LD: Organization on the landing; WebPage,
  CreativeWork, Person or Service elsewhere. Shared through core/head.
- The proxy-derived origin moves to core/origin.ts, used by the page
  shell, the landing and both server routes.

In development only /api/* reaches Nitro, so the two files 404 under
`npm start`; they were checked against a production build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pigui
2026-09-29 15:21:59 +02:00
parent 399b8d5450
commit 86b7485b32
17 changed files with 639 additions and 22 deletions

View File

@@ -171,6 +171,18 @@ for (const listed of data['/public/v1/members']) {
};
}
// What the sitemap is built from, and one renamed project to exercise the
// redirect middleware with.
data['/public/v1/slugs'] = {
pages: data['/public/v1/pages'].map((p) => ({ id: p.id, updated_at: p.updated_at, alternates: p.alternates })),
projects: data['/public/v1/projects'].map((p) => ({
id: p.id,
updated_at: p.updated_at,
alternates: data[`/public/v1/projects/${p.slug}`].alternates,
})),
};
data['/public/v1/redirects'] = [{ from: '/proyectos/catalogo-viejo', to: '/proyectos/catalogo', status: 301, locale: null }];
createServer((req, res) => {
const path = new URL(req.url, 'http://x').pathname.replace(/^\/api/, '');
const payload = data[path];