From 4837dc4eef3b98e0362dc5c9dbf18172824e6f99 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 19 Jun 2024 14:27:54 +0800 Subject: [PATCH 01/27] =?UTF-8?q?example=E6=B7=B1=E8=89=B2=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/example/components/BlogListPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/example/components/BlogListPage.js b/themes/example/components/BlogListPage.js index b8a1e573..79934d77 100644 --- a/themes/example/components/BlogListPage.js +++ b/themes/example/components/BlogListPage.js @@ -45,7 +45,7 @@ export const BlogListPage = props => { : `${pagePrefix}/page/${currentPage - 1}`, query: router.query.s ? { s: router.query.s } : {} }} - className={`${showPrev ? 'bg-black ' : 'bg-gray pointer-events-none '} text-white no-underline py-2 px-3 rounded`}> + className={`${showPrev ? 'bg-black dark:bg-hexo-black-gray' : 'bg-gray pointer-events-none invisible'} text-white no-underline py-2 px-3 rounded`}> {locale.PAGINATION.PREV} { pathname: `${pagePrefix}/page/${currentPage + 1}`, query: router.query.s ? { s: router.query.s } : {} }} - className={`${showNext ? 'bg-black ' : 'bg-gray pointer-events-none '} text-white no-underline py-2 px-3 rounded`}> + className={`${showNext ? 'bg-black dark:bg-hexo-black-gray ' : 'bg-gray pointer-events-none invisible'} text-white no-underline py-2 px-3 rounded`}> {locale.PAGINATION.NEXT} From e502f454b83d243a76167bc8781dd21707549470 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 19 Jun 2024 15:47:14 +0800 Subject: [PATCH 02/27] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dexport=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E5=A4=8D=E6=9D=82url=E7=9A=84=E8=AE=BF?= =?UTF-8?q?=E9=97=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/db/getSiteData.js | 3 ++- next.config.js | 10 ++++++++++ pages/[prefix]/[slug]/[...suffix].js | 20 ++++++++++---------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index fb916374..84e764fb 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -5,7 +5,7 @@ import getAllPageIds from '@/lib/notion/getAllPageIds' import { getAllTags } from '@/lib/notion/getAllTags' import { getConfigMapFromConfigPage } from '@/lib/notion/getNotionConfig' import getPageProperties, { - adjustPageProperties + adjustPageProperties } from '@/lib/notion/getPageProperties' import { fetchInBatches, getPage } from '@/lib/notion/getPostBlocks' import { compressImage, mapImgUrl } from '@/lib/notion/mapImage' @@ -512,6 +512,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) { adjustPageProperties(element, NOTION_CONFIG) }) + // 站点基础信息 const siteInfo = getSiteInfo({ collection, block, pageId }) // 文章计数 diff --git a/next.config.js b/next.config.js index ce46d750..54b30cac 100644 --- a/next.config.js +++ b/next.config.js @@ -32,6 +32,16 @@ const locales = (function () { return langs })() +// 编译前执行 +const preBuild = (function () { + // 删除 public/sitemap.xml 文件 ; 否则会和/pages/sitemap.xml.js 冲突。 + const sitemapPath = path.resolve(__dirname, 'public', 'sitemap.xml') + if (fs.existsSync(sitemapPath)) { + fs.unlinkSync(sitemapPath) + console.log('Deleted existing sitemap.xml from public directory') + } +})() + /** * 扫描指定目录下的文件夹名,用于获取所有主题 * @param {*} directory diff --git a/pages/[prefix]/[slug]/[...suffix].js b/pages/[prefix]/[slug]/[...suffix].js index 8e645faa..d9567c4c 100644 --- a/pages/[prefix]/[slug]/[...suffix].js +++ b/pages/[prefix]/[slug]/[...suffix].js @@ -30,17 +30,17 @@ export async function getStaticPaths() { const from = 'slug-paths' const { allPages } = await getGlobalData({ from }) - + const paths = allPages + ?.filter(row => checkSlugHasMorThanTwoSlash(row)) + .map(row => ({ + params: { + prefix: row.slug.split('/')[0], + slug: row.slug.split('/')[1], + suffix: row.slug.split('/').slice(2) + } + })) return { - paths: allPages - ?.filter(row => checkSlugHasMorThanTwoSlash(row)) - .map(row => ({ - params: { - prefix: row.slug.split('/')[0], - slug: row.slug.split('/')[1], - suffix: row.slug.split('/').slice(1) - } - })), + paths: paths, fallback: true } } From 96d5e2ebee0f89a224730ba6949a4f313c3b26ab Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 19 Jun 2024 16:20:57 +0800 Subject: [PATCH 03/27] =?UTF-8?q?gitbook=20=E5=8A=A0=E5=85=A5=E7=A4=BE?= =?UTF-8?q?=E4=BA=A4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/gitbook/components/Footer.js | 5 +- themes/gitbook/components/SocialButton.js | 193 +++++++++++++++++++--- 2 files changed, 172 insertions(+), 26 deletions(-) diff --git a/themes/gitbook/components/Footer.js b/themes/gitbook/components/Footer.js index d0e2a150..0335509d 100644 --- a/themes/gitbook/components/Footer.js +++ b/themes/gitbook/components/Footer.js @@ -1,4 +1,5 @@ import { siteConfig } from '@/lib/config' +import SocialButton from './SocialButton' const Footer = ({ siteInfo }) => { const d = new Date() @@ -11,7 +12,9 @@ const Footer = ({ siteInfo }) => {