Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 19, 2024
2 parents af8b1b9 + ab21294 commit e5e662d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
case 'POST_URL_PREFIX_MAPPING_CATEGORY':
case 'IS_TAG_COLOR_DISTINGUISHED':
case 'TAG_SORT_BY_COUNT':
case 'LINK':
return convertVal(extendConfig[key] || defaultVal || BLOG[key])
default:
}
Expand Down
22 changes: 11 additions & 11 deletions lib/notion/getNotionConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function getConfigMapFromConfigPage(allPages) {
})

if (!configPage) {
console.warn('[Notion配置] 未找到配置页面')
// console.warn('[Notion配置] 未找到配置页面')
return null
}
const configPageId = configPage.id
Expand All @@ -51,11 +51,11 @@ export async function getConfigMapFromConfigPage(allPages) {
}

if (!content) {
console.warn(
'[Notion配置] 未找到配置表格',
pageRecordMap.block[configPageId],
pageRecordMap.block[configPageId].value
)
// console.warn(
// '[Notion配置] 未找到配置表格',
// pageRecordMap.block[configPageId],
// pageRecordMap.block[configPageId].value
// )
return null
}

Expand All @@ -66,11 +66,11 @@ export async function getConfigMapFromConfigPage(allPages) {

// eslint-disable-next-line no-constant-condition, no-self-compare
if (!configTableId) {
console.warn(
'[Notion配置]未找到配置表格数据',
pageRecordMap.block[configPageId],
pageRecordMap.block[configPageId].value
)
// console.warn(
// '[Notion配置]未找到配置表格数据',
// pageRecordMap.block[configPageId],
// pageRecordMap.block[configPageId].value
// )
return null
}

Expand Down
20 changes: 12 additions & 8 deletions lib/sitemap.xml.js
Original file line number Diff line number Diff line change
@@ -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'
}
Expand All @@ -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'
})
Expand Down

0 comments on commit e5e662d

Please sign in to comment.