diff --git a/lib/notion/convertInnerUrl.js b/lib/notion/convertInnerUrl.js index 76317a1a..017bebd1 100644 --- a/lib/notion/convertInnerUrl.js +++ b/lib/notion/convertInnerUrl.js @@ -30,8 +30,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 = langPrefix + 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 47598cf1..dbe65ff9 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()) ) {