-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathsitemap.ts
More file actions
48 lines (43 loc) · 1.06 KB
/
sitemap.ts
File metadata and controls
48 lines (43 loc) · 1.06 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
import type { MetadataRoute } from 'next'
import { getAllPostMeta } from '@/lib/blog/registry'
import { getBaseUrl } from '@/lib/core/utils/urls'
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const baseUrl = getBaseUrl()
const now = new Date()
const staticPages: MetadataRoute.Sitemap = [
{
url: baseUrl,
lastModified: now,
},
{
url: `${baseUrl}/blog`,
lastModified: now,
},
{
url: `${baseUrl}/blog/tags`,
lastModified: now,
},
// {
// url: `${baseUrl}/templates`,
// lastModified: now,
// },
{
url: `${baseUrl}/changelog`,
lastModified: now,
},
{
url: `${baseUrl}/terms`,
lastModified: new Date('2024-10-14'),
},
{
url: `${baseUrl}/privacy`,
lastModified: new Date('2024-10-14'),
},
]
const posts = await getAllPostMeta()
const blogPages: MetadataRoute.Sitemap = posts.map((p) => ({
url: p.canonical,
lastModified: new Date(p.updated ?? p.date),
}))
return [...staticPages, ...blogPages]
}