portfolio/app/sitemap.ts

25 lines
746 B
TypeScript
Raw Normal View History

2023-07-31 21:24:30 +00:00
import {MetadataRoute} from 'next'
import {getAllArticles} from '@/lib/getAllArticles'
2023-07-29 22:40:36 +00:00
2023-07-31 21:24:30 +00:00
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const urls = [
'https://ryanfreeman.dev/',
'https://ryanfreeman.dev/about',
'https://ryanfreeman.dev/dashboard',
'https://ryanfreeman.dev/writing',
'https://ryanfreeman.dev/projects',
'https://ryanfreeman.dev/uses'
2023-07-29 22:40:36 +00:00
]
2023-07-31 21:24:30 +00:00
const pages = urls.map(url => ({
url,
lastModified: new Date()
}))
const posts = (await getAllArticles()).map(({slug, date}) => ({
2023-07-31 21:42:13 +00:00
url: `https://ryanfreeman.dev/writing/${slug}/`,
2023-07-31 21:24:30 +00:00
lastModified: new Date(date).toISOString()
}))
return [...pages, ...posts]
2023-07-29 22:40:36 +00:00
}