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 7ced2e85726..9efbd684c3e 100644 --- a/themes/commerce/index.js +++ b/themes/commerce/index.js @@ -246,7 +246,7 @@ const LayoutSlug = props => {
{lock && } - {!lock && ( + {!lock && post && (
@@ -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 60b896c1f4f..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) @@ -178,7 +178,7 @@ const LayoutSlug = props => { <> {lock ? ( - ) : ( + ) : post && (
diff --git a/themes/fukasawa/index.js b/themes/fukasawa/index.js index 96936df8229..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) @@ -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/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 9bab5daffc8..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) @@ -292,7 +292,7 @@ const LayoutSlug = props => { {/* 文章锁 */} {lock && } - {!lock && ( + {!lock && post && (
{/* 文章主体 */}
{ 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) @@ -286,7 +286,7 @@ const LayoutSlug = props => {
{lock && } - {!lock && ( + {!lock && post && (
{ // 延时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 1b01c3bb75f..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) @@ -177,7 +177,7 @@ const LayoutSlug = props => { {/* 文章锁 */} {lock && } - {!lock && ( + {!lock && post && (
{/* 文章信息 */} 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 7cbcad19ddb..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) @@ -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' && ( @@ -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 ee5eb121f4e..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) @@ -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..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) @@ -315,7 +315,7 @@ const LayoutSlug = props => { return ( <> - {!lock ? ( + {!lock ? post && (
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 ed2b6ea6ea4..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) @@ -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..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) @@ -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..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) @@ -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..020bbf4e215 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' && ( + <> + + + + )} - {/* 评论区 */} - -
+ {/* 评论区 */} + +
+ )} ) } @@ -271,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) 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 && (