This repository was archived by the owner on Mar 24, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsitemap.ts
More file actions
92 lines (86 loc) · 2.2 KB
/
sitemap.ts
File metadata and controls
92 lines (86 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { getAllPostsAsPostType } from '@/lib/blog';
import type { MetadataRoute } from 'next';
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const baseUrl = 'https://allthingslinux.org';
// Define static routes
const staticRoutes = [
{
url: baseUrl,
lastModified: new Date(),
changeFrequency: 'daily' as const,
priority: 1,
// Add Open Graph image to sitemap
images: [`${baseUrl}/images/og.png`],
},
{
url: `${baseUrl}/about`,
lastModified: new Date(),
changeFrequency: 'monthly' as const,
priority: 0.8,
},
{
url: `${baseUrl}/code-of-conduct`,
lastModified: new Date(),
changeFrequency: 'monthly' as const,
priority: 0.8,
},
{
url: `${baseUrl}/blog`,
lastModified: new Date(),
changeFrequency: 'daily' as const,
priority: 0.9,
},
{
url: `${baseUrl}/get-involved`,
lastModified: new Date(),
changeFrequency: 'monthly' as const,
priority: 0.8,
},
];
// Add distribution logos to sitemap for better image SEO
const distributionLogos = [
'arch',
'gentoo',
'bazzite',
'debian',
'cachy',
'fedora',
'mint',
'bedrock',
'asahi',
'ubuntu',
'opensuse',
'nixos',
'redhat',
'slackware',
].map((distro) => ({
url: `${baseUrl}/images/hero/${distro}.png`,
lastModified: new Date(),
changeFrequency: 'yearly' as const,
priority: 0.3,
}));
// Get all blog posts and add them to sitemap
const posts = getAllPostsAsPostType();
const blogPosts = posts.map((post) => ({
url: `${baseUrl}/blog/${post.categorySlug}/${post.slug}`,
lastModified: new Date(post.date),
changeFrequency: 'monthly' as const,
priority: 0.7,
}));
// Get unique categories and add them to sitemap
const categories = Array.from(
new Set(posts.map((post) => post.categorySlug))
);
const categoryPages = categories.map((category) => ({
url: `${baseUrl}/blog/${category}`,
lastModified: new Date(),
changeFrequency: 'daily' as const,
priority: 0.8,
}));
return [
...staticRoutes,
...distributionLogos,
...categoryPages,
...blogPosts,
];
}