Skip to content

Commit

Permalink
修复sitemap 路径
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Jul 21, 2023
1 parent d9b1319 commit aad96b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/sitemap.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ export async function generateSitemapXml({ allPages }) {
changefreq: 'daily'
}]

// 循环页面生成
allPages?.forEach(post => {
const slugWithoutLeadingSlash = post?.slug?.startsWith('/') ? post?.slug?.slice(1) : post.slug
urls.push({
loc: `${BLOG.LINK}/${post.slug}`,
loc: `${BLOG.LINK}/${slugWithoutLeadingSlash}`,
lastmod: new Date(post?.publishTime).toISOString().split('T')[0],
changefreq: 'daily'
})
Expand Down
3 changes: 2 additions & 1 deletion pages/sitemap.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export const getServerSideProps = async (ctx) => {
}
]
const postFields = allPages?.filter(p => p.status === BLOG.NOTION_PROPERTY_NAME.status_publish)?.map(post => {
const slugWithoutLeadingSlash = post?.slug.startsWith('/') ? post?.slug?.slice(1) : post.slug
return {
loc: `${BLOG.LINK}/${post.slug}`,
loc: `${BLOG.LINK}/${slugWithoutLeadingSlash}`,
lastmod: new Date(post?.publishTime).toISOString().split('T')[0],
changefreq: 'daily',
priority: '0.7'
Expand Down

0 comments on commit aad96b0

Please sign in to comment.