diff --git a/lib/sitemap.xml.js b/lib/sitemap.xml.js index c847e57d..1ff513f7 100644 --- a/lib/sitemap.xml.js +++ b/lib/sitemap.xml.js @@ -6,7 +6,11 @@ import { siteConfig } from './config' * @param {*} param0 */ export async function generateSitemapXml({ allPages, NOTION_CONFIG }) { - const link = siteConfig('LINK', BLOG.LINK, NOTION_CONFIG) + let link = siteConfig('LINK', BLOG.LINK, NOTION_CONFIG) + // 确保链接不以斜杠结尾 + if (link && link.endsWith('/')) { + link = link.slice(0, -1) + } const urls = [ { loc: `${link}`, diff --git a/pages/sitemap.xml.js b/pages/sitemap.xml.js index e6b33bb2..06c21f42 100644 --- a/pages/sitemap.xml.js +++ b/pages/sitemap.xml.js @@ -38,6 +38,11 @@ export const getServerSideProps = async ctx => { } function generateLocalesSitemap(link, allPages, locale) { + // 确保链接不以斜杠结尾 + if (link && link.endsWith('/')) { + link = link.slice(0, -1) + } + if (locale && locale.length > 0 && locale.indexOf('/') !== 0) { locale = '/' + locale }