From 45a6ec1eb4effa6c2c1b7fcab63a2b30fd15c7f4 Mon Sep 17 00:00:00 2001 From: anime Date: Fri, 20 Dec 2024 18:15:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=9B=B4=E6=8D=A2short=5Fid=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E6=96=B9=E5=BC=8F):=20=E9=81=BF=E5=85=8D=E5=9B=A0?= =?UTF-8?q?=E4=B8=BA=E7=BC=A9=E7=9F=AD=E5=AF=BC=E8=87=B4=E7=9A=84=E6=BD=9C?= =?UTF-8?q?=E5=9C=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 6d73a4388c1613dc0a719d68c8b4b3432fefd314) --- lib/notion/convertInnerUrl.js | 5 ++--- lib/utils/pageId.js | 5 +---- themes/gitbook/index.js | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/notion/convertInnerUrl.js b/lib/notion/convertInnerUrl.js index 0a8cfbce..b632e245 100644 --- a/lib/notion/convertInnerUrl.js +++ b/lib/notion/convertInnerUrl.js @@ -27,8 +27,7 @@ export const convertInnerUrl = allPages => { const slug = getLastPartOfUrl(anchorTag.href) if (checkStrIsNotionId(slug)) { const slugPage = allPages?.find(page => { - const find = idToUuid(slug).indexOf(page.short_id) === 0 - return find + return idToUuid(slug).indexOf(page.short_id) === 14 }) if (slugPage) { anchorTag.href = slugPage?.href @@ -51,4 +50,4 @@ export const convertInnerUrl = allPages => { } } } -} +} \ No newline at end of file diff --git a/lib/utils/pageId.js b/lib/utils/pageId.js index c963df28..6bd39885 100644 --- a/lib/utils/pageId.js +++ b/lib/utils/pageId.js @@ -38,10 +38,7 @@ function getShortId(uuid) { if (!uuid || uuid.indexOf('-') < 0) { return uuid } - // 找到第一个 '-' 的位置 - const index = uuid.indexOf('-') - // 截取从开始到第一个 '-' 之前的部分 - return uuid.substring(0, index) + return uuid.substring(14) } module.exports = { extractLangPrefix, extractLangId, getShortId } diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index b737e9f8..003f2f5c 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -78,7 +78,7 @@ function getNavPagesWithLatest(allNavPages, latestPosts, post) { } // 属于最新文章通常6篇 && (无阅读记录 || 最近更新时间大于上次阅读时间) if ( - latestPosts.some(post => post?.id.indexOf(item?.short_id) === 0) && + latestPosts.some(post => post?.id.indexOf(item?.short_id) === 14) && (!postReadTime[item.short_id] || postReadTime[item.short_id] < new Date(item.lastEditedDate).getTime()) ) {