From ea74dc3faed12ff0ba007c9af3911b182804fb43 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 28 Jun 2024 17:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=85=8D=E7=BD=AE=E4=BA=86pr?= =?UTF-8?q?efix=E5=90=8E=EF=BC=8C=E9=83=A8=E5=88=86=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=89=93=E5=BC=80=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/getPageProperties.js | 13 +++++++++---- pages/[prefix]/index.js | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js index 95796c2f62..53d7ce8765 100644 --- a/lib/notion/getPageProperties.js +++ b/lib/notion/getPageProperties.js @@ -6,9 +6,9 @@ import formatDate from '../utils/formatDate' import md5 from 'js-md5' import { siteConfig } from '../config' import { - checkStartWithHttp, - convertUrlStartWithOneSlash, - getLastSegmentFromUrl + checkStartWithHttp, + convertUrlStartWithOneSlash, + getLastSegmentFromUrl } from '../utils' import { extractLangPrefix } from '../utils/pageId' import { mapImgUrl } from './mapImage' @@ -290,5 +290,10 @@ function generateCustomizeSlug(postProperties, NOTION_CONFIG) { if (fullPrefix.endsWith('/')) { fullPrefix = fullPrefix.substring(0, fullPrefix.length - 1) // 去掉尾部部的"/" } - return `${fullPrefix}/${postProperties.slug ?? postProperties.id}` + + if(fullPrefix){ + return `${fullPrefix}/${postProperties.slug ?? postProperties.id}` + }else{ + return `${postProperties.slug ?? postProperties.id}` + } } diff --git a/pages/[prefix]/index.js b/pages/[prefix]/index.js index 4231a18189..dc480fcc53 100644 --- a/pages/[prefix]/index.js +++ b/pages/[prefix]/index.js @@ -129,7 +129,7 @@ export async function getStaticProps({ params: { prefix }, locale }) { fullSlug += '.html' } } - + // 在列表内查找文章 props.post = props?.allPages?.find(p => { return (