-
-
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.
feat: create
sitemap.js
in every routes
- Loading branch information
1 parent
c45f6d9
commit d271dbd
Showing
5 changed files
with
44 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { WEBSITE_URL, PATH_DOCS } from '@/constants'; | ||
import { readMarkdownTagTree } from '@/utils/fs'; | ||
|
||
export default async function sitemap() { | ||
const tagTree = await readMarkdownTagTree(PATH_DOCS); | ||
|
||
return Object.keys(tagTree).map(tag => ({ | ||
url: `${WEBSITE_URL}/categories/${tag}`, | ||
lastModified: new Date(), | ||
changeFrequency: 'weekly', | ||
priority: 0.8, | ||
})); | ||
} |
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,13 @@ | ||
import { WEBSITE_URL, PATH_DOCS, EXT_MD_REGEXP } from '@/constants'; | ||
import { readMarkdownFilesFromDir } from '@/utils/fs'; | ||
|
||
export default async function sitemap() { | ||
const markdownDocuments = await readMarkdownFilesFromDir(PATH_DOCS); | ||
|
||
return markdownDocuments.map(({ basename, data: { updated } }) => ({ | ||
url: `${WEBSITE_URL}/posts/${basename.replace(EXT_MD_REGEXP, '')}`, | ||
lastModified: updated, | ||
changeFrequency: 'monthly', | ||
priority: 1.0, | ||
})); | ||
} |
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,12 @@ | ||
import { WEBSITE_URL } from '@/constants'; | ||
|
||
export default function sitemap() { | ||
return [ | ||
{ | ||
url: WEBSITE_URL, | ||
lastModified: new Date(), | ||
changeFrequency: 'monthly', | ||
priority: 0.5, | ||
}, | ||
]; | ||
} |
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