sitemap.xml问题

This commit is contained in:
tangly1024.com
2024-11-18 14:22:39 +08:00
parent ce18359527
commit ab2129464f
3 changed files with 24 additions and 19 deletions

View File

@@ -1,25 +1,29 @@
import BLOG from '@/blog.config'
import fs from 'fs'
export async function generateSitemapXml({ allPages }) {
import { siteConfig } from './config'
/**
* 生成站点地图
* @param {*} param0
*/
export async function generateSitemapXml({ allPages, NOTION_CONFIG }) {
const link = siteConfig('LINK', null, NOTION_CONFIG)
const urls = [
{
loc: `${BLOG.LINK}`,
loc: `${link}`,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily'
},
{
loc: `${BLOG.LINK}/archive`,
loc: `${link}/archive`,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily'
},
{
loc: `${BLOG.LINK}/category`,
loc: `${link}/category`,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily'
},
{
loc: `${BLOG.LINK}/tag`,
loc: `${link}/tag`,
lastmod: new Date().toISOString().split('T')[0],
changefreq: 'daily'
}
@@ -30,7 +34,7 @@ export async function generateSitemapXml({ allPages }) {
? post?.slug?.slice(1)
: post.slug
urls.push({
loc: `${BLOG.LINK}/${slugWithoutLeadingSlash}`,
loc: `${link}/${slugWithoutLeadingSlash}`,
lastmod: new Date(post?.publishDay).toISOString().split('T')[0],
changefreq: 'daily'
})