From 0aaf97e88b85477d6009931efe59e25588cc51ce Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 21 Mar 2022 14:14:13 +0800 Subject: [PATCH] =?UTF-8?q?HEXO=20=E4=B8=BB=E9=A2=98=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/LayoutBase.js | 9 ++++- themes/hexo/LayoutSlug.js | 2 +- themes/hexo/components/ArticleAdjacent.js | 25 ++++++++++++++ themes/hexo/components/ArticleCopyright.js | 39 ++++++++++++++++++++++ themes/hexo/components/ArticleDetail.js | 8 ++++- themes/hexo/components/LoadingCover.js | 8 +++++ themes/hexo/config_hexo.js | 3 ++ 7 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 themes/hexo/components/ArticleAdjacent.js create mode 100644 themes/hexo/components/ArticleCopyright.js create mode 100644 themes/hexo/components/LoadingCover.js diff --git a/themes/hexo/LayoutBase.js b/themes/hexo/LayoutBase.js index 7979f625..3f0872ea 100644 --- a/themes/hexo/LayoutBase.js +++ b/themes/hexo/LayoutBase.js @@ -8,6 +8,8 @@ import TopNav from './components/TopNav' import smoothscroll from 'smoothscroll-polyfill' import FloatDarkModeButton from './components/FloatDarkModeButton' import Live2D from '@/components/Live2D' +import LoadingCover from './components/LoadingCover' +import { useGlobal } from '@/lib/global' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -20,6 +22,7 @@ const LayoutBase = (props) => { const [show, switchShow] = useState(false) // const [percent, changePercent] = useState(0) // 页面阅读百分比 const rightAreaSlot = + const { onLoading } = useGlobal() const scrollListener = () => { const targetRef = document.getElementById('wrapper') @@ -43,6 +46,7 @@ const LayoutBase = (props) => { return (
+ {headerSlot} @@ -50,7 +54,10 @@ const LayoutBase = (props) => {
-
{children}
+
+ {onLoading ? : children} +
+
diff --git a/themes/hexo/LayoutSlug.js b/themes/hexo/LayoutSlug.js index 7851f153..5e152c72 100644 --- a/themes/hexo/LayoutSlug.js +++ b/themes/hexo/LayoutSlug.js @@ -52,7 +52,7 @@ export const LayoutSlug = props => { showTag={false} floatSlot={floatSlot} > -
+
diff --git a/themes/hexo/components/ArticleAdjacent.js b/themes/hexo/components/ArticleAdjacent.js new file mode 100644 index 00000000..b7e36420 --- /dev/null +++ b/themes/hexo/components/ArticleAdjacent.js @@ -0,0 +1,25 @@ +import Link from 'next/link' +import CONFIG_HEXO from '../config_hexo' + +/** + * 上一篇,下一篇文章 + * @param {prev,next} param0 + * @returns + */ +export default function ArticleAdjacent ({ prev, next }) { + if (!prev || !next || !CONFIG_HEXO.ARTICLE_ADJACENT) { + return <> + } + return
+ + + {prev.title} + + + + {next.title} + + + +
+} diff --git a/themes/hexo/components/ArticleCopyright.js b/themes/hexo/components/ArticleCopyright.js new file mode 100644 index 00000000..42a27552 --- /dev/null +++ b/themes/hexo/components/ArticleCopyright.js @@ -0,0 +1,39 @@ +import BLOG from '@/blog.config' +import { useGlobal } from '@/lib/global' +import Link from 'next/link' +import { useRouter } from 'next/router' +import { useEffect, useState } from 'react' +import CONFIG_HEXO from '../config_hexo' + +export default function ArticleCopyright () { + if (!CONFIG_HEXO.ARTICLE_COPYRIGHT) { + return <> + } + const router = useRouter() + const [path, setPath] = useState(BLOG.LINK + router.asPath) + useEffect(() => { + setPath(window.location.href) + }) + + const { locale } = useGlobal() + return
+
    +
  • + {locale.COMMON.AUTHOR}: + + {BLOG.AUTHOR} + +
  • +
  • + {locale.COMMON.URL}: + + {path} + +
  • +
  • + {locale.COMMON.COPYRIGHT}: + {locale.COMMON.COPYRIGHT_NOTICE} +
  • +
+
+} diff --git a/themes/hexo/components/ArticleDetail.js b/themes/hexo/components/ArticleDetail.js index aa4dbb4c..f0fa966b 100644 --- a/themes/hexo/components/ArticleDetail.js +++ b/themes/hexo/components/ArticleDetail.js @@ -8,13 +8,16 @@ import 'prismjs/components/prism-python' import 'prismjs/components/prism-typescript' import { useEffect, useRef } from 'react' import { Code, Collection, CollectionRow, Equation, NotionRenderer } from 'react-notion-x' +import ArticleAdjacent from './ArticleAdjacent' +import ArticleCopyright from './ArticleCopyright' /** * * @param {*} param0 * @returns */ -export default function ArticleDetail ({ post, recommendPosts, prev, next }) { +export default function ArticleDetail (props) { + const { post } = props const zoom = typeof window !== 'undefined' && mediumZoom({ container: '.notion-viewport', background: 'rgba(0, 0, 0, 0.2)', @@ -63,6 +66,9 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) { data-ad-slot="3806269138"/> + + +
diff --git a/themes/hexo/components/LoadingCover.js b/themes/hexo/components/LoadingCover.js new file mode 100644 index 00000000..c6418fad --- /dev/null +++ b/themes/hexo/components/LoadingCover.js @@ -0,0 +1,8 @@ +export default function LoadingCover () { + return (
+
+ +
+
+ ) +} diff --git a/themes/hexo/config_hexo.js b/themes/hexo/config_hexo.js index ef5c2d02..8b5b6723 100644 --- a/themes/hexo/config_hexo.js +++ b/themes/hexo/config_hexo.js @@ -14,6 +14,9 @@ const CONFIG_HEXO = { POST_LIST_PREVIEW: true, // 读取文章预览 NAV_TYPE: 'autoCollapse', // ['fixed','autoCollapse','normal'] 分别是固定屏幕顶部、屏幕顶部自动折叠,不固定 + ARTICLE_ADJACENT: true, // 显示上一篇下一篇文章推荐 + ARTICLE_COPYRIGHT: true, // 显示文章版权声明 + WIDGET_TO_TOP: true, WIDGET_TO_COMMENT: true, // 跳到评论区 WIDGET_DARK_MODE: true, // 夜间模式