From 33740681637e2b265138fb4fce562fc1eedbafeb Mon Sep 17 00:00:00 2001 From: anime Date: Fri, 8 Nov 2024 00:14:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(=E4=BD=BF=E6=89=80=E6=9C=89=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E7=9A=84404=E8=83=BD=E5=A4=9F=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E8=BF=90=E8=BD=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 3e3b7667d043522a3d782b804815b8f1683127d1) --- themes/commerce/index.js | 2 +- themes/example/index.js | 2 +- themes/fukasawa/index.js | 2 +- themes/game/index.js | 2 +- themes/heo/index.js | 2 +- themes/hexo/index.js | 2 +- themes/magzine/index.js | 2 +- themes/matery/index.js | 2 +- themes/medium/index.js | 2 +- themes/movie/index.js | 2 +- themes/nobelium/index.js | 2 +- themes/photo/index.js | 2 +- themes/plog/index.js | 2 +- themes/simple/index.js | 52 +++++++++++++++++++++------------------- themes/starter/index.js | 2 +- 15 files changed, 41 insertions(+), 39 deletions(-) diff --git a/themes/commerce/index.js b/themes/commerce/index.js index 7ced2e85726..f415f8e5200 100644 --- a/themes/commerce/index.js +++ b/themes/commerce/index.js @@ -246,7 +246,7 @@ const LayoutSlug = props => {
{lock && } - {!lock && ( + {!lock && post && (
diff --git a/themes/example/index.js b/themes/example/index.js index 60b896c1f4f..2d6ecfefaee 100644 --- a/themes/example/index.js +++ b/themes/example/index.js @@ -178,7 +178,7 @@ const LayoutSlug = props => { <> {lock ? ( - ) : ( + ) : post && (
diff --git a/themes/fukasawa/index.js b/themes/fukasawa/index.js index 96936df8229..2167a95027f 100644 --- a/themes/fukasawa/index.js +++ b/themes/fukasawa/index.js @@ -159,7 +159,7 @@ const LayoutSlug = props => { <> {lock ? ( - ) : ( + ) : post && ( )} diff --git a/themes/game/index.js b/themes/game/index.js index 718f6a92a8c..04bc192ccf5 100644 --- a/themes/game/index.js +++ b/themes/game/index.js @@ -307,7 +307,7 @@ const LayoutSlug = props => { <> {lock && } - {!lock && ( + {!lock && post && (
diff --git a/themes/heo/index.js b/themes/heo/index.js index 9bab5daffc8..42bfcb83f45 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -292,7 +292,7 @@ const LayoutSlug = props => { {/* 文章锁 */} {lock && } - {!lock && ( + {!lock && post && (
{/* 文章主体 */}
{
{lock && } - {!lock && ( + {!lock && post && (
{ {/* 文章锁 */} {lock && } - {!lock && ( + {!lock && post && (
{/* 文章信息 */} diff --git a/themes/matery/index.js b/themes/matery/index.js index 7cbcad19ddb..13a5992f094 100644 --- a/themes/matery/index.js +++ b/themes/matery/index.js @@ -253,7 +253,7 @@ const LayoutSlug = props => { className={`${fullWidth ? '' : '-mt-32'} transition-all duration-300 rounded-md mx-3 lg:border lg:rounded-xl lg:py-4 bg-white dark:bg-hexo-black-gray dark:border-black`}> {lock && } - {!lock && ( + {!lock && post && (
{/* 文章信息 */} {post?.type && post?.type === 'Post' && ( diff --git a/themes/medium/index.js b/themes/medium/index.js index ee5eb121f4e..b51db693622 100644 --- a/themes/medium/index.js +++ b/themes/medium/index.js @@ -209,7 +209,7 @@ const LayoutSlug = props => { {/* 文章锁 */} {lock && } - {!lock && ( + {!lock && post && (
{/* 文章信息 */} diff --git a/themes/movie/index.js b/themes/movie/index.js index 00b90346c4e..c205d6d02b8 100644 --- a/themes/movie/index.js +++ b/themes/movie/index.js @@ -315,7 +315,7 @@ const LayoutSlug = props => { return ( <> - {!lock ? ( + {!lock ? post && (
diff --git a/themes/nobelium/index.js b/themes/nobelium/index.js index ed2b6ea6ea4..44afc5c004a 100644 --- a/themes/nobelium/index.js +++ b/themes/nobelium/index.js @@ -243,7 +243,7 @@ const LayoutSlug = props => { <> {lock && } - {!lock && ( + {!lock && post && (
<> diff --git a/themes/photo/index.js b/themes/photo/index.js index f369e6fb28c..64f6a1f06b5 100644 --- a/themes/photo/index.js +++ b/themes/photo/index.js @@ -315,7 +315,7 @@ const LayoutSlug = props => { return ( <> - {!lock ? ( + {!lock ? post && (
diff --git a/themes/plog/index.js b/themes/plog/index.js index be778f685b7..b715206f42a 100644 --- a/themes/plog/index.js +++ b/themes/plog/index.js @@ -198,7 +198,7 @@ const LayoutSlug = props => { <> {lock && } - {!lock && ( + {!lock && post && (
<> diff --git a/themes/simple/index.js b/themes/simple/index.js index 397e6a69d34..29516202e1a 100644 --- a/themes/simple/index.js +++ b/themes/simple/index.js @@ -224,35 +224,37 @@ const LayoutSlug = props => { <> {lock && } -
- {/* 文章信息 */} - - - {/* 广告嵌入 */} - {/* */} - - -
- {/* Notion文章主体 */} - {!lock && } -
+ {!lock && post && ( +
+ {/* 文章信息 */} + + + {/* 广告嵌入 */} + {/* */} + + +
+ {/* Notion文章主体 */} + {!lock && } +
- {/* 分享 */} - + {/* 分享 */} + - {/* 广告嵌入 */} - + {/* 广告嵌入 */} + - {post?.type === 'Post' && ( - <> - - - - )} + {post?.type === 'Post' && ( + <> + + + + )} - {/* 评论区 */} - -
+ {/* 评论区 */} + +
+ )} ) } diff --git a/themes/starter/index.js b/themes/starter/index.js index 35d837bd559..c4f9af8c032 100644 --- a/themes/starter/index.js +++ b/themes/starter/index.js @@ -159,7 +159,7 @@ const LayoutSlug = props => {
{lock && } - {!lock && ( + {!lock && post && (
From c8d90a41660c0fff27601b4316880eddbfe8ae8f Mon Sep 17 00:00:00 2001 From: anime Date: Fri, 8 Nov 2024 00:30:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(=E4=BD=BF=E6=89=80=E6=9C=89=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E7=9A=84404=E8=83=BD=E5=A4=9F=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E8=BF=90=E8=BD=AC):=20=E5=90=8C=E6=97=B6=E8=AE=A9=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=96=87=E7=AB=A0DOM=E8=8A=82=E7=82=B9=E4=B9=9F?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=85=AC=E5=91=8A=E6=A0=8F=E7=AD=89=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E4=BD=8D=E7=BD=AE=E7=9A=84=E5=B9=B2=E6=89=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/WordCount.js | 2 +- themes/commerce/index.js | 2 +- themes/example/index.js | 2 +- themes/fukasawa/index.js | 2 +- themes/gitbook/index.js | 4 ++-- themes/heo/index.js | 2 +- themes/hexo/index.js | 4 ++-- themes/landing/index.js | 2 +- themes/magzine/index.js | 2 +- themes/matery/components/WordCount.js | 2 +- themes/matery/index.js | 4 ++-- themes/medium/index.js | 2 +- themes/movie/index.js | 4 ++-- themes/nav/index.js | 2 +- themes/next/components/WordCount.js | 2 +- themes/next/index.js | 2 +- themes/nobelium/index.js | 2 +- themes/photo/index.js | 4 ++-- themes/plog/index.js | 2 +- themes/simple/index.js | 2 +- 20 files changed, 25 insertions(+), 25 deletions(-) diff --git a/components/WordCount.js b/components/WordCount.js index 315c58d39a7..7f7066cf1d6 100644 --- a/components/WordCount.js +++ b/components/WordCount.js @@ -28,7 +28,7 @@ export default function WordCount() { * 更新字数统计和阅读时间 */ function countWords() { - const articleText = deleteHtmlTag(document.getElementById('notion-article')?.innerHTML) + const articleText = deleteHtmlTag(document.querySelector('#article-wrapper #notion-article')?.innerHTML) const wordCount = fnGetCpmisWords(articleText) // 阅读速度 300-500每分钟 document.getElementById('wordCount').innerHTML = wordCount diff --git a/themes/commerce/index.js b/themes/commerce/index.js index f415f8e5200..9efbd684c3e 100644 --- a/themes/commerce/index.js +++ b/themes/commerce/index.js @@ -304,7 +304,7 @@ const Layout404 = props => { // 延时3秒如果加载失败就返回首页 setTimeout(() => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/').then(() => { // console.log('找不到页面', router.asPath) diff --git a/themes/example/index.js b/themes/example/index.js index 2d6ecfefaee..d78e20a4561 100644 --- a/themes/example/index.js +++ b/themes/example/index.js @@ -162,7 +162,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/fukasawa/index.js b/themes/fukasawa/index.js index 2167a95027f..0e2cf9d3623 100644 --- a/themes/fukasawa/index.js +++ b/themes/fukasawa/index.js @@ -143,7 +143,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index 9898f0aeeb9..0fac89b5f9b 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -255,7 +255,7 @@ const LayoutIndex = props => { // 重定向到指定文章 router.push(index).then(() => { setTimeout(() => { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { console.log( '请检查您的Notion数据库中是否包含此slug页面: ', @@ -309,7 +309,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/heo/index.js b/themes/heo/index.js index 42bfcb83f45..aafe116e32b 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -273,7 +273,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/hexo/index.js b/themes/hexo/index.js index fe90a26b829..49d20a31447 100644 --- a/themes/hexo/index.js +++ b/themes/hexo/index.js @@ -269,7 +269,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) @@ -333,7 +333,7 @@ const Layout404 = props => { // 延时3秒如果加载失败就返回首页 setTimeout(() => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/').then(() => { // console.log('找不到页面', router.asPath) diff --git a/themes/landing/index.js b/themes/landing/index.js index 62d8f9db844..9dbb3be6158 100644 --- a/themes/landing/index.js +++ b/themes/landing/index.js @@ -82,7 +82,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/magzine/index.js b/themes/magzine/index.js index c5814d36003..e5165bdd771 100644 --- a/themes/magzine/index.js +++ b/themes/magzine/index.js @@ -155,7 +155,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/matery/components/WordCount.js b/themes/matery/components/WordCount.js index 8e4af32a6f5..d7d7c02b526 100644 --- a/themes/matery/components/WordCount.js +++ b/themes/matery/components/WordCount.js @@ -29,7 +29,7 @@ export default function WordCount() { * 更新字数统计和阅读时间 */ function countWords() { - const articleText = deleteHtmlTag(document.getElementById('notion-article')?.innerHTML) + const articleText = deleteHtmlTag(document.querySelector('#article-wrapper #notion-article')?.innerHTML) const wordCount = fnGetCpmisWords(articleText) // 阅读速度 300-500每分钟 document.getElementById('wordCount').innerHTML = wordCount diff --git a/themes/matery/index.js b/themes/matery/index.js index 13a5992f094..cb844a5df66 100644 --- a/themes/matery/index.js +++ b/themes/matery/index.js @@ -231,7 +231,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) @@ -320,7 +320,7 @@ const Layout404 = props => { setTimeout(() => { const article = typeof document !== 'undefined' && - document.getElementById('notion-article') + document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/').then(() => { // console.log('找不到页面', router.asPath) diff --git a/themes/medium/index.js b/themes/medium/index.js index b51db693622..dfd37ce2cc0 100644 --- a/themes/medium/index.js +++ b/themes/medium/index.js @@ -191,7 +191,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/movie/index.js b/themes/movie/index.js index c205d6d02b8..6e969b7d7f3 100644 --- a/themes/movie/index.js +++ b/themes/movie/index.js @@ -156,7 +156,7 @@ const LayoutSlug = props => { // 用js 实现将页面中的多个视频聚合为一个分集的视频 function combineVideo() { // 找到 id 为 notion-article 的元素 - const notionArticle = document.getElementById('notion-article') + const notionArticle = document.querySelector('#article-wrapper #notion-article') if (!notionArticle) return // 如果找不到对应的元素,则退出函数 // 找到所有的 .notion-asset-wrapper 元素 @@ -291,7 +291,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/nav/index.js b/themes/nav/index.js index 48b3aaba64e..ed405186e97 100755 --- a/themes/nav/index.js +++ b/themes/nav/index.js @@ -261,7 +261,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/next/components/WordCount.js b/themes/next/components/WordCount.js index ccf146d453b..6cfd1cc6336 100644 --- a/themes/next/components/WordCount.js +++ b/themes/next/components/WordCount.js @@ -23,7 +23,7 @@ export default function WordCount() { * 更新字数统计和阅读时间 */ function countWords() { - const articleText = deleteHtmlTag(document.getElementById('notion-article')?.innerHTML) + const articleText = deleteHtmlTag(document.querySelector('#article-wrapper #notion-article')?.innerHTML) const wordCount = fnGetCpmisWords(articleText) // 阅读速度 300-500每分钟 document.getElementById('wordCount').innerHTML = wordCount diff --git a/themes/next/index.js b/themes/next/index.js index b7408f8a327..8c70fb8ff81 100644 --- a/themes/next/index.js +++ b/themes/next/index.js @@ -328,7 +328,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/nobelium/index.js b/themes/nobelium/index.js index 44afc5c004a..c8324277afa 100644 --- a/themes/nobelium/index.js +++ b/themes/nobelium/index.js @@ -227,7 +227,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/photo/index.js b/themes/photo/index.js index 64f6a1f06b5..b76eef756ce 100644 --- a/themes/photo/index.js +++ b/themes/photo/index.js @@ -156,7 +156,7 @@ const LayoutSlug = props => { // 用js 实现将页面中的多个视频聚合为一个分集的视频 function combineVideo() { // 找到 id 为 notion-article 的元素 - const notionArticle = document.getElementById('notion-article') + const notionArticle = document.querySelector('#article-wrapper #notion-article') if (!notionArticle) return // 如果找不到对应的元素,则退出函数 // 找到所有的 .notion-asset-wrapper 元素 @@ -291,7 +291,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/plog/index.js b/themes/plog/index.js index b715206f42a..4de0ba0a288 100644 --- a/themes/plog/index.js +++ b/themes/plog/index.js @@ -182,7 +182,7 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) diff --git a/themes/simple/index.js b/themes/simple/index.js index 29516202e1a..020bbf4e215 100644 --- a/themes/simple/index.js +++ b/themes/simple/index.js @@ -273,7 +273,7 @@ const Layout404 = props => { setTimeout( () => { if (isBrowser) { - const article = document.getElementById('notion-article') + const article = document.querySelector('#article-wrapper #notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath)