From 2d64451dfe9b1bf362e5cc3a5e94e3a6b217ba61 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sun, 1 Jan 2023 18:55:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/[...slug].js | 1 - pages/sitemap.xml.js | 21 +++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pages/[...slug].js b/pages/[...slug].js index b4e1d47e..3013696d 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -108,7 +108,6 @@ export async function getStaticPaths() { export async function getStaticProps({ params: { slug } }) { let fullSlug = slug.join('/') - console.log('[读取Notion]', fullSlug) if (BLOG.PSEUDO_STATIC) { if (!fullSlug.endsWith('.html')) { fullSlug += '.html' diff --git a/pages/sitemap.xml.js b/pages/sitemap.xml.js index 403d6cd7..083edc0b 100644 --- a/pages/sitemap.xml.js +++ b/pages/sitemap.xml.js @@ -7,41 +7,40 @@ export const getServerSideProps = async (ctx) => { const { allPages } = await getGlobalNotionData({ from: 'rss' }) const defaultFields = [ { - loc: `${BLOG.LINK}`, // Absolute url + loc: `${BLOG.LINK}`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/archive`, // Absolute url + loc: `${BLOG.LINK}/archive`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/category`, // Absolute url + loc: `${BLOG.LINK}/category`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/feed`, // Absolute url + loc: `${BLOG.LINK}/feed`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/search`, // Absolute url + loc: `${BLOG.LINK}/search`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/tag`, // Absolute url + loc: `${BLOG.LINK}/tag`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' } ] const postFields = allPages?.map(post => { - console.log(post) return { - loc: `${BLOG.LINK}/${post.slug}`, // Absolute url + loc: `${BLOG.LINK}/${post.slug}`, lastmod: new Date(post?.date?.start_date || post?.createdTime), changefreq: 'daily', priority: '0.7' @@ -49,6 +48,12 @@ export const getServerSideProps = async (ctx) => { }) const fields = defaultFields.concat(postFields) + // 缓存 + // ctx.res.setHeader( + // 'Cache-Control', + // 'public, s-maxage=10, stale-while-revalidate=59' + // ) + return getServerSideSitemap(ctx, fields) }