()
| 26 | |
| 27 | // This allows us to generate a `sitemap.xml` file dynamically based on the needs of the Node.js Website |
| 28 | const 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 | |
| 48 | export default sitemap; |
| 49 |
nothing calls this directly
no test coverage detected