forked from CaliCastle/cali.so
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45d16a8
commit 0e17c5c
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { type MetadataRoute } from 'next' | ||
|
||
import { url } from '~/lib' | ||
import { getAllLatestBlogPostSlugs } from '~/sanity/queries' | ||
|
||
export default async function sitemap() { | ||
const staticMap = [ | ||
{ | ||
url: url('/').href, | ||
lastModified: new Date(), | ||
}, | ||
{ | ||
url: url('/blog').href, | ||
lastModified: new Date(), | ||
}, | ||
] satisfies MetadataRoute.Sitemap | ||
|
||
const slugs = await getAllLatestBlogPostSlugs() | ||
|
||
const dynamicMap = slugs.map((slug) => ({ | ||
url: url(`/blog/${slug}`).href, | ||
lastModified: new Date(), | ||
})) satisfies MetadataRoute.Sitemap | ||
|
||
return [...staticMap, ...dynamicMap] | ||
} | ||
|
||
export const runtime = 'edge' | ||
export const revalidate = 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function url(path = '') { | ||
const baseUrl = | ||
process.env.NODE_ENV === 'production' | ||
? 'https://cali.so' | ||
: 'http://localhost:3000' | ||
|
||
return new URL(path, baseUrl) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters