-
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
Showing
5 changed files
with
84 additions
and
18 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 type { MetadataRoute } from 'next'; | ||
import { MyProfile } from '~/about/headline/data/profile'; | ||
|
||
export default function robots(): MetadataRoute.Robots { | ||
return { | ||
rules: { | ||
userAgent: '*', | ||
allow: '/', | ||
disallow: ['/favicon', '/fonts', '/images', '/open.mp4'], | ||
}, | ||
sitemap: `${MyProfile.blog.href}/sitemap.xml`, | ||
}; | ||
} |
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,60 @@ | ||
import type { MetadataRoute } from 'next'; | ||
import { MyProfile } from '~/about/headline/data/profile'; | ||
import { getAllPosts, getAllTags } from '~/shared/helpers/post'; | ||
|
||
export default function sitemap(): MetadataRoute.Sitemap { | ||
const DOMAIN = MyProfile.blog.href; | ||
const PRIORITY = { | ||
VERY_HIGH: 1, | ||
HIGH: 0.8, | ||
MID: 0.5, | ||
}; | ||
|
||
const posts = getAllPosts(['tags']); | ||
const tags = getAllTags(); | ||
|
||
const postUrls: MetadataRoute.Sitemap = posts.map((post) => ({ | ||
url: `${DOMAIN}/posts/${post.url}`, | ||
lastModified: new Date(post.updatedAt ?? post.date), | ||
changeFrequency: 'daily', | ||
priority: PRIORITY.VERY_HIGH, | ||
})); | ||
const tagUrls: MetadataRoute.Sitemap = tags.map((tag) => { | ||
const post = posts.find((post) => post.tags.includes(tag))!; | ||
return { | ||
url: `${DOMAIN}/tags/${tag}`, | ||
lastModified: new Date(post.date ?? post.updatedAt), | ||
changeFrequency: 'weekly', | ||
priority: PRIORITY.MID, | ||
}; | ||
}); | ||
|
||
return [ | ||
{ | ||
url: DOMAIN, | ||
lastModified: new Date(), | ||
changeFrequency: 'monthly', | ||
priority: PRIORITY.MID, | ||
}, | ||
{ | ||
url: `${DOMAIN}/about`, | ||
lastModified: new Date(), | ||
changeFrequency: 'weekly', | ||
priority: PRIORITY.VERY_HIGH, | ||
}, | ||
{ | ||
url: `${DOMAIN}/posts`, | ||
lastModified: new Date(), | ||
changeFrequency: 'weekly', | ||
priority: PRIORITY.HIGH, | ||
}, | ||
{ | ||
url: `${DOMAIN}/tags`, | ||
lastModified: new Date(), | ||
changeFrequency: 'weekly', | ||
priority: PRIORITY.MID, | ||
}, | ||
...postUrls, | ||
...tagUrls, | ||
]; | ||
} |
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
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