sitemap.ts 965 B

123456789101112131415161718192021222324252627282930313233
  1. import type { MetadataRoute } from 'next';
  2. import { source } from '@/lib/source';
  3. import { i18n } from '@/lib/i18n';
  4. import { siteUrl } from '@/lib/shared';
  5. // Required for `output: 'export'`.
  6. export const dynamic = 'force-static';
  7. // Locale home pages + the canonical (English) docs pages. Other locales
  8. // currently fall back to English content, so we don't list them separately
  9. // to avoid duplicate-content entries until real translations exist.
  10. export default function sitemap(): MetadataRoute.Sitemap {
  11. const entries: MetadataRoute.Sitemap = [];
  12. for (const lang of i18n.languages) {
  13. const prefix = lang === 'en' ? '' : `/${lang}`;
  14. entries.push({
  15. url: `${siteUrl}${prefix}` || siteUrl,
  16. changeFrequency: 'weekly',
  17. priority: 1,
  18. });
  19. }
  20. for (const page of source.getPages('en')) {
  21. entries.push({
  22. url: `${siteUrl}${page.url}`,
  23. changeFrequency: 'weekly',
  24. priority: 0.8,
  25. });
  26. }
  27. return entries;
  28. }