Skip to content

Commit fe78443

Browse files
author
Lasim
committed
refactor(sitemap): simplify page retrieval and enhance sitemap entry mapping
1 parent e2fd045 commit fe78443

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

app/sitemap.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,17 @@ import { source } from '@/lib/source';
33

44
export const dynamic = 'force-static';
55

6-
function getPages(tree: any): any[] {
7-
const pages: any[] = [];
8-
9-
function traverse(nodes: any[]) {
10-
for (const node of nodes) {
11-
if (node.type === 'page') {
12-
pages.push(node);
13-
} else if ('children' in node) {
14-
traverse(node.children);
15-
}
16-
}
17-
}
18-
19-
traverse(tree.children);
20-
return pages;
21-
}
22-
236
export default function sitemap(): MetadataRoute.Sitemap {
24-
const pages = getPages(source.pageTree).map((page) => ({
7+
// Get all pages from source.getPages() which combines all sources
8+
const allPages = source.getPages();
9+
10+
// Map pages to sitemap entries
11+
const sitemapEntries = allPages.map((page) => ({
2512
url: new URL(page.url, 'https://docs.deploystack.io').toString(),
26-
lastModified: page.lastModified,
13+
lastModified: page.data.lastModified ? new Date(page.data.lastModified) : undefined,
14+
changeFrequency: 'weekly' as const,
15+
priority: page.url === '/' ? 1.0 : page.url.startsWith('/development') || page.url.startsWith('/self-hosted') ? 0.7 : 0.8,
2716
}));
2817

29-
return pages;
18+
return sitemapEntries;
3019
}

0 commit comments

Comments
 (0)