[PR #427] [MERGED] fix: sitemap XML namespaces, video entries, and alternate-language links #565

Closed
opened 2026-05-06 13:08:47 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/427
Author: @JaredStowell
Created: 3/10/2026
Status: Merged
Merged: 3/10/2026
Merged by: @james-elicx

Base: mainHead: jstowell/fix-sitemap-media-and-alternates


📝 Commits (1)

  • 3df0de1 Update metadata sitemap XML

📊 Changes

4 files changed (+407 additions, -49 deletions)

View changed files

📝 packages/vinext/src/server/metadata-routes.ts (+82 -33)
📝 tests/app-router.test.ts (+9 -0)
📝 tests/fixtures/app-basic/app/sitemap.ts (+15 -0)
📝 tests/metadata-routes.test.ts (+301 -16)

📄 Description

Fix sitemapToXml() so it matches Next.js sitemap behavior for media and alternates.

This PR:

  • adds xmlns:image when image entries are present
  • adds xmlns:video when video entries are present
  • adds xmlns:xhtml when alternates are present
  • serializes alternates.languages as <xhtml:link ... />
  • serializes videos as <video:video> blocks
  • aligns sitemap field ordering and edge-case behavior with Next.js resolveSitemap()

Why

This fixes three reported sitemap bugs:

  1. image tags were emitted without the required namespace
  2. video entries were accepted by the type but ignored during serialization
  3. alternate-language links were accepted by the type but ignored during serialization

Tests

Added and expanded coverage for:

  • image namespace emission
  • video namespace and tag emission
  • alternate-language namespace and tag emission
  • mixed namespace gating
  • ordering of alternates, images, videos, and metadata fields
  • parity edge cases against Next.js behavior
  • end-to-end /sitemap.xml output from the App Router fixture

Validation

Ran:

  • pnpm test tests/metadata-routes.test.ts
  • pnpm test tests/app-router.test.ts -t "serves /sitemap.xml from dynamic sitemap.ts"
  • pnpm test tests/shims.test.ts -t "sitemapToXml"
  • pnpm run fmt
  • pnpm run typecheck
  • pnpm run lint
  • pnpm run build
  • pnpm test

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/427 **Author:** [@JaredStowell](https://github.com/JaredStowell) **Created:** 3/10/2026 **Status:** ✅ Merged **Merged:** 3/10/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `jstowell/fix-sitemap-media-and-alternates` --- ### 📝 Commits (1) - [`3df0de1`](https://github.com/cloudflare/vinext/commit/3df0de177776ab73cfaaf551fb8a3f955cbb1fbd) Update metadata sitemap XML ### 📊 Changes **4 files changed** (+407 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/metadata-routes.ts` (+82 -33) 📝 `tests/app-router.test.ts` (+9 -0) 📝 `tests/fixtures/app-basic/app/sitemap.ts` (+15 -0) 📝 `tests/metadata-routes.test.ts` (+301 -16) </details> ### 📄 Description Fix `sitemapToXml()` so it matches Next.js sitemap behavior for media and alternates. This PR: - adds `xmlns:image` when image entries are present - adds `xmlns:video` when video entries are present - adds `xmlns:xhtml` when alternates are present - serializes `alternates.languages` as `<xhtml:link ... />` - serializes `videos` as `<video:video>` blocks - aligns sitemap field ordering and edge-case behavior with Next.js `resolveSitemap()` ## Why This fixes three reported sitemap bugs: 1. image tags were emitted without the required namespace 2. video entries were accepted by the type but ignored during serialization 3. alternate-language links were accepted by the type but ignored during serialization ## Tests Added and expanded coverage for: - image namespace emission - video namespace and tag emission - alternate-language namespace and tag emission - mixed namespace gating - ordering of alternates, images, videos, and metadata fields - parity edge cases against Next.js behavior - end-to-end `/sitemap.xml` output from the App Router fixture ## Validation Ran: - `pnpm test tests/metadata-routes.test.ts` - `pnpm test tests/app-router.test.ts -t "serves /sitemap.xml from dynamic sitemap.ts"` - `pnpm test tests/shims.test.ts -t "sitemapToXml"` - `pnpm run fmt` - `pnpm run typecheck` - `pnpm run lint` - `pnpm run build` - `pnpm test` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:47 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#565
No description provided.