From 0a14f096631c68fb0105c6230eb6990c12011182 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sun, 4 Jun 2023 14:03:22 +0800 Subject: [PATCH 1/3] fix-404 --- pages/[...slug].js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pages/[...slug].js b/pages/[...slug].js index 846ff7eb..43e3d17a 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -3,13 +3,13 @@ import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' import * as ThemeMap from '@/themes' -import React from 'react' +import { useEffect, useState } from 'react' import { idToUuid } from 'notion-utils' -import Router from 'next/router' -import { isBrowser } from '@/lib/utils' +import Router, { useRouter } from 'next/router' import { getNotion } from '@/lib/notion/getNotion' import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents' import md5 from 'js-md5' +import { isBrowser } from '@/lib/utils' /** * 根据notion的slug访问页面 @@ -20,13 +20,17 @@ const Slug = props => { const { theme, changeLoadingState } = useGlobal() const ThemeComponents = ThemeMap[theme] const { post, siteInfo } = props - const router = Router.useRouter() + const router = useRouter() // 文章锁🔐 - const [lock, setLock] = React.useState(post?.password && post?.password !== '') + const [lock, setLock] = useState(post?.password && post?.password !== '') - React.useEffect(() => { - changeLoadingState(false) + useEffect(() => { + if (post) { + changeLoadingState(false) + } else { + changeLoadingState(true) + } if (post?.password && post?.password !== '') { setLock(true) } else { @@ -42,7 +46,7 @@ const Slug = props => { if (!post) { setTimeout(() => { if (isBrowser()) { - const article = document.getElementById('container') + const article = document.getElementById('notion-article') if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) From eb22dee6288cfad789084c02d0921acd4f02f615 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sun, 4 Jun 2023 14:11:16 +0800 Subject: [PATCH 2/3] comment --- components/Comment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Comment.js b/components/Comment.js index e1b1f6bb..42b69f9e 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -1,7 +1,7 @@ import BLOG from '@/blog.config' import dynamic from 'next/dynamic' import Tabs from '@/components/Tabs' -import React from 'react' +import { useEffect } from 'react' import { useRouter } from 'next/router' const WalineComponent = dynamic( @@ -57,7 +57,7 @@ const ValineComponent = dynamic(() => import('@/components/ValineComponent'), { const Comment = ({ frontMatter }) => { const router = useRouter() - React.useEffect(() => { + useEffect(() => { // 跳转到评论区 setTimeout(() => { if (window.location.href.indexOf('target=comment') > -1) { From 209343e649359ea90bc1af40fe51969b8b7afa49 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 6 Jun 2023 14:15:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?hexo=20=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/components/BlogPostCard.js | 2 +- themes/hexo/components/BlogPostCardInfo.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index 234acdac..5882f265 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -34,7 +34,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { {/* 图片封面 */} {showPageCover && (
- +
diff --git a/themes/hexo/components/BlogPostCardInfo.js b/themes/hexo/components/BlogPostCardInfo.js index a741c059..d89c126b 100644 --- a/themes/hexo/components/BlogPostCardInfo.js +++ b/themes/hexo/components/BlogPostCardInfo.js @@ -13,7 +13,7 @@ export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary
{/* 标题 */}