MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / sitemap

Function sitemap

apps/site/app/sitemap.ts:28–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27// This allows us to generate a `sitemap.xml` file dynamically based on the needs of the Node.js Website
28const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
29 // Gets a list of all statically available routes
30 const routes = await dynamicRouter.getAllRoutes();
31
32 const currentDate = new Date().toISOString();
33
34 const getSitemapEntry = (r: string, locales: Array<string> = []) => ({
35 url: getFullPath(r, defaultLocale.code),
36 lastModified: currentDate,
37 changeFrequency: 'always' as const,
38 alternates: { languages: getAlternatePaths(r, locales) },
39 });
40
41 const staticPaths = routes.map(r => getSitemapEntry(r, nonDefaultLocales));
42 const blogPaths = BLOG_DYNAMIC_ROUTES.map(r => getSitemapEntry(`blog/${r}`));
43 const externalPaths = EXTERNAL_LINKS_SITEMAP.map(r => getSitemapEntry(r));
44
45 return [...staticPaths, ...blogPaths, ...externalPaths];
46};
47
48export default sitemap;
49

Callers

nothing calls this directly

Calls 1

getSitemapEntryFunction · 0.85

Tested by

no test coverage detected