From 10f6f0f958c298f604adcff61971d5f9b5b4fe76 Mon Sep 17 00:00:00 2001 From: EFL Date: Sat, 13 Jul 2024 09:36:07 +0800 Subject: [PATCH 1/9] =?UTF-8?q?change=20"=E6=9B=B4=E5=A4=9A=E2=80=9C=20to?= =?UTF-8?q?=20"=E6=8E=A8=E8=8D=90=E6=96=87=E7=AB=A0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/heo/components/Hero.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/heo/components/Hero.js b/themes/heo/components/Hero.js index e8d9802356b..47cbd24ac7b 100644 --- a/themes/heo/components/Hero.js +++ b/themes/heo/components/Hero.js @@ -383,7 +383,8 @@ function TodayCard({ cRef, siteInfo }) { } />
- {locale.COMMON.MORE} + {/* EFL-UPDATED */} + 推荐文章
From 31221d2372ddd15a07c2b539a7a196c3e222b7d7 Mon Sep 17 00:00:00 2001 From: EFL Date: Sat, 13 Jul 2024 20:37:02 +0800 Subject: [PATCH 2/9] update timeout --- themes/theme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/theme.js b/themes/theme.js index 1931d46ee63..d97952975d7 100644 --- a/themes/theme.js +++ b/themes/theme.js @@ -67,7 +67,7 @@ export const getLayoutByTheme = ({ router, theme }) => { } else { setTimeout(() => { checkThemeDOM() - }, 100) + }, 1000) const components = ThemeComponents[getLayoutNameByPath(router.pathname, router.asPath)] if (components) { From c7518deef1591269bfafff592eb2e49b83567fc0 Mon Sep 17 00:00:00 2001 From: EFL Date: Sat, 13 Jul 2024 20:39:47 +0800 Subject: [PATCH 3/9] rollback --- themes/theme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/theme.js b/themes/theme.js index d97952975d7..1931d46ee63 100644 --- a/themes/theme.js +++ b/themes/theme.js @@ -67,7 +67,7 @@ export const getLayoutByTheme = ({ router, theme }) => { } else { setTimeout(() => { checkThemeDOM() - }, 1000) + }, 100) const components = ThemeComponents[getLayoutNameByPath(router.pathname, router.asPath)] if (components) { From 3d8e7c9c5f88e613c34f6d370d5d3bb95633b6ee Mon Sep 17 00:00:00 2001 From: EFL Date: Sun, 14 Jul 2024 10:52:42 +0800 Subject: [PATCH 4/9] test --- lib/notion/getPostBlocks.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js index 8bac9e2ad3f..469fa8f724c 100644 --- a/lib/notion/getPostBlocks.js +++ b/lib/notion/getPostBlocks.js @@ -123,6 +123,16 @@ function filterPostBlocks(id, blockMap, slice) { const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}` b.value.properties.source[0][0] = newUrl } + + if (b?.value?.type === 'synced_block' && b?.value?.properties?.children) { + const childBlocks = b.value.properties.children; + delete clonePageBlock.block[blockId]; + // Insert child blocks at the sync block's position + blockIds.splice(i + 1, 0, ...childBlocks); + // Adjust the loop counter to process the newly inserted blocks + i--; + continue; + } } // 去掉不用的字段 From e1046197a07c13f50b4733a0c19f8d75e4e85cd2 Mon Sep 17 00:00:00 2001 From: EFL Date: Sun, 14 Jul 2024 10:58:59 +0800 Subject: [PATCH 5/9] fix --- lib/notion/getPostBlocks.js | 43 +++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js index 469fa8f724c..54dde7ff1f1 100644 --- a/lib/notion/getPostBlocks.js +++ b/lib/notion/getPostBlocks.js @@ -81,23 +81,41 @@ export async function getPageWithRetry(id, from, retryAttempts = 3) { function filterPostBlocks(id, blockMap, slice) { const clonePageBlock = deepClone(blockMap) let count = 0 + const blocksToProcess = Object.keys(clonePageBlock?.block || {}) // 循环遍历文档的每个block for (const i in clonePageBlock?.block) { - const b = clonePageBlock?.block[i] + for (let i = 0; i < blocksToProcess.length; i++) { + const blockId = blocksToProcess[i] + const b = clonePageBlock?.block[blockId] + if (slice && slice > 0 && count > slice) { - delete clonePageBlock?.block[i] + delete clonePageBlock?.block[blockId] continue } - // 当BlockId等于PageId时移除 + if (b?.value?.id === id) { - // 此block含有敏感信息 delete b?.value?.properties continue } - + count++ - // 处理 c++、c#、汇编等语言名字映射 + + if (b?.value?.type === 'sync_block' && b?.value?.children) { + const childBlocks = b.value.children + // Remove the sync block + delete clonePageBlock.block[blockId] + // Insert child blocks in place of the sync block + childBlocks.forEach((childBlock, index) => { + const newBlockId = `${blockId}_child_${index}` + clonePageBlock.block[newBlockId] = childBlock + blocksToProcess.splice(i + index + 1, 0, newBlockId) + }) + // Adjust the loop counter to process the newly inserted blocks + i-- + continue + } + if (b?.value?.type === 'code') { if (b?.value?.properties?.language?.[0][0] === 'C++') { b.value.properties.language[0][0] = 'cpp' @@ -109,8 +127,7 @@ function filterPostBlocks(id, blockMap, slice) { b.value.properties.language[0][0] = 'asm6502' } } - - // 如果是文件,或嵌入式PDF,需要重新加密签名 + if ( (b?.value?.type === 'file' || b?.value?.type === 'pdf' || @@ -123,16 +140,6 @@ function filterPostBlocks(id, blockMap, slice) { const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}` b.value.properties.source[0][0] = newUrl } - - if (b?.value?.type === 'synced_block' && b?.value?.properties?.children) { - const childBlocks = b.value.properties.children; - delete clonePageBlock.block[blockId]; - // Insert child blocks at the sync block's position - blockIds.splice(i + 1, 0, ...childBlocks); - // Adjust the loop counter to process the newly inserted blocks - i--; - continue; - } } // 去掉不用的字段 From 11f34d47486ecaf155ee8955b39fe05dc781db33 Mon Sep 17 00:00:00 2001 From: EFL Date: Sun, 14 Jul 2024 11:00:33 +0800 Subject: [PATCH 6/9] fix2 --- lib/notion/getPostBlocks.js | 105 ++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js index 54dde7ff1f1..3ba777299ad 100644 --- a/lib/notion/getPostBlocks.js +++ b/lib/notion/getPostBlocks.js @@ -84,63 +84,62 @@ function filterPostBlocks(id, blockMap, slice) { const blocksToProcess = Object.keys(clonePageBlock?.block || {}) // 循环遍历文档的每个block - for (const i in clonePageBlock?.block) { - for (let i = 0; i < blocksToProcess.length; i++) { - const blockId = blocksToProcess[i] - const b = clonePageBlock?.block[blockId] - - if (slice && slice > 0 && count > slice) { - delete clonePageBlock?.block[blockId] - continue + for (let i = 0; i < blocksToProcess.length; i++) { + const blockId = blocksToProcess[i] + const b = clonePageBlock?.block[blockId] + + if (slice && slice > 0 && count > slice) { + delete clonePageBlock?.block[blockId] + continue + } + + if (b?.value?.id === id) { + delete b?.value?.properties + continue + } + + count++ + + if (b?.value?.type === 'sync_block' && b?.value?.children) { + const childBlocks = b.value.children + // Remove the sync block + delete clonePageBlock.block[blockId] + // Insert child blocks in place of the sync block + childBlocks.forEach((childBlock, index) => { + const newBlockId = `${blockId}_child_${index}` + clonePageBlock.block[newBlockId] = childBlock + blocksToProcess.splice(i + index + 1, 0, newBlockId) + }) + // Adjust the loop counter to process the newly inserted blocks + i-- + continue + } + + if (b?.value?.type === 'code') { + if (b?.value?.properties?.language?.[0][0] === 'C++') { + b.value.properties.language[0][0] = 'cpp' } - - if (b?.value?.id === id) { - delete b?.value?.properties - continue + if (b?.value?.properties?.language?.[0][0] === 'C#') { + b.value.properties.language[0][0] = 'csharp' } - - count++ - - if (b?.value?.type === 'sync_block' && b?.value?.children) { - const childBlocks = b.value.children - // Remove the sync block - delete clonePageBlock.block[blockId] - // Insert child blocks in place of the sync block - childBlocks.forEach((childBlock, index) => { - const newBlockId = `${blockId}_child_${index}` - clonePageBlock.block[newBlockId] = childBlock - blocksToProcess.splice(i + index + 1, 0, newBlockId) - }) - // Adjust the loop counter to process the newly inserted blocks - i-- - continue - } - - if (b?.value?.type === 'code') { - if (b?.value?.properties?.language?.[0][0] === 'C++') { - b.value.properties.language[0][0] = 'cpp' - } - if (b?.value?.properties?.language?.[0][0] === 'C#') { - b.value.properties.language[0][0] = 'csharp' - } - if (b?.value?.properties?.language?.[0][0] === 'Assembly') { - b.value.properties.language[0][0] = 'asm6502' - } - } - - if ( - (b?.value?.type === 'file' || - b?.value?.type === 'pdf' || - b?.value?.type === 'video' || - b?.value?.type === 'audio') && - b?.value?.properties?.source?.[0][0] && - b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0 - ) { - const oldUrl = b?.value?.properties?.source?.[0][0] - const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}` - b.value.properties.source[0][0] = newUrl + if (b?.value?.properties?.language?.[0][0] === 'Assembly') { + b.value.properties.language[0][0] = 'asm6502' } } + + if ( + (b?.value?.type === 'file' || + b?.value?.type === 'pdf' || + b?.value?.type === 'video' || + b?.value?.type === 'audio') && + b?.value?.properties?.source?.[0][0] && + b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0 + ) { + const oldUrl = b?.value?.properties?.source?.[0][0] + const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}` + b.value.properties.source[0][0] = newUrl + } +} // 去掉不用的字段 if (id === BLOG.NOTION_PAGE_ID) { From 2045b418733c0d884e19414e89b46fb2c57b8d78 Mon Sep 17 00:00:00 2001 From: EFL Date: Sun, 14 Jul 2024 11:20:29 +0800 Subject: [PATCH 7/9] add comment --- lib/notion/getPostBlocks.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js index 3ba777299ad..2859345f72c 100644 --- a/lib/notion/getPostBlocks.js +++ b/lib/notion/getPostBlocks.js @@ -93,7 +93,9 @@ function filterPostBlocks(id, blockMap, slice) { continue } + // 当BlockId等于PageId时移除 if (b?.value?.id === id) { + // 此block含有敏感信息 delete b?.value?.properties continue } @@ -102,19 +104,20 @@ function filterPostBlocks(id, blockMap, slice) { if (b?.value?.type === 'sync_block' && b?.value?.children) { const childBlocks = b.value.children - // Remove the sync block + // 移除同步块 delete clonePageBlock.block[blockId] - // Insert child blocks in place of the sync block + // 用子块替代同步块 childBlocks.forEach((childBlock, index) => { const newBlockId = `${blockId}_child_${index}` clonePageBlock.block[newBlockId] = childBlock blocksToProcess.splice(i + index + 1, 0, newBlockId) }) - // Adjust the loop counter to process the newly inserted blocks + // 重新处理新加入的子块 i-- continue } + // 处理 c++、c#、汇编等语言名字映射 if (b?.value?.type === 'code') { if (b?.value?.properties?.language?.[0][0] === 'C++') { b.value.properties.language[0][0] = 'cpp' @@ -127,6 +130,7 @@ function filterPostBlocks(id, blockMap, slice) { } } + // 如果是文件,或嵌入式PDF,需要重新加密签名 if ( (b?.value?.type === 'file' || b?.value?.type === 'pdf' || From 222f58e48784c624f3a5c8eba451eadc06ac3f47 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 24 Jul 2024 10:47:46 +0800 Subject: [PATCH 8/9] confirm --- lib/lang/en-US.js | 1 + lib/lang/zh-CN.js | 1 + themes/heo/components/Hero.js | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 4d1e177be3e..6b40a44cdaa 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -22,6 +22,7 @@ export default { COMMON: { THEME: 'Theme', ARTICLE_LIST: 'Article List', + RECOMMEND_POSTS: 'Recommend Posts', MORE: 'More', NO_MORE: 'No More', LATEST_POSTS: 'Latest posts', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index 85535fd6af2..c49ed54431f 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -22,6 +22,7 @@ export default { COMMON: { THEME: 'Theme', ARTICLE_LIST: '文章列表', + RECOMMEND_POSTS: '推荐文章', MORE: '更多', NO_MORE: '没有更多了', LATEST_POSTS: '最新发布', diff --git a/themes/heo/components/Hero.js b/themes/heo/components/Hero.js index 47cbd24ac7b..b22c640fd9f 100644 --- a/themes/heo/components/Hero.js +++ b/themes/heo/components/Hero.js @@ -383,8 +383,7 @@ function TodayCard({ cRef, siteInfo }) { } />
- {/* EFL-UPDATED */} - 推荐文章 + {locale.COMMON.RECOMMEND_POSTS}
From 677c2e07b30aafb4ae222427f5a8c489be160b7e Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 24 Jul 2024 11:00:17 +0800 Subject: [PATCH 9/9] =?UTF-8?q?heo=20=E4=B8=BB=E9=A2=98=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/heo/components/BlogPostCard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/heo/components/BlogPostCard.js b/themes/heo/components/BlogPostCard.js index 5b567422908..afd11ce66d7 100644 --- a/themes/heo/components/BlogPostCard.js +++ b/themes/heo/components/BlogPostCard.js @@ -30,7 +30,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { {/* 图片封面 */} {showPageCover && ( -
+