diff --git a/components/Comment.js b/components/Comment.js index 075b6ba6..82be7170 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -23,7 +23,7 @@ const Comment = ({ frontMatter }) => { const router = useRouter() const { locale } = useGlobal() return ( -
+
{BLOG.COMMENT_UTTERRANCES_REPO && (
diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 928e7295..5e02c979 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -24,6 +24,7 @@ export default { AUTHOR: 'Author', URL: 'URL', POSTS: 'Posts', + ARTICLE: 'Article', VISITORS: 'Visitors', VIEWS: 'Views', COPYRIGHT_NOTICE: 'All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index 02e07cf0..915c1a9a 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -26,6 +26,7 @@ export default { URL: '链接', ANALYTICS: '统计', POSTS: '篇文章', + ARTICLE: '文章', VISITORS: '位访客', VIEWS: '次查看', COPYRIGHT_NOTICE: '本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。', diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 62691554..0ce1263f 100644 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -97,7 +97,11 @@ async function getCustomNav ({ notionPageData }) { const customNav = [] if (allPage && allPage.length > 0) { allPage.forEach(p => { - customNav.push({ icon: p.icon || null, name: p.title, to: '/' + p.slug, show: true }) + if (p?.slug?.indexOf('http') === 0) { + customNav.push({ icon: p.icon || null, name: p.title, to: p.slug, show: true }) + } else { + customNav.push({ icon: p.icon || null, name: p.title, to: '/' + p.slug, show: true }) + } }) } return customNav diff --git a/pages/[slug].js b/pages/[slug].js index d513f334..5b1a6412 100644 --- a/pages/[slug].js +++ b/pages/[slug].js @@ -29,8 +29,10 @@ export async function getStaticPaths () { const from = 'slug-paths' const { allPosts } = await getGlobalNotionData({ from, pageType: ['Page'] }) + const filterPosts = allPosts?.filter(e => e?.slug?.indexOf('http') !== 0) || [] + return { - paths: allPosts.map(row => ({ params: { slug: row.slug } })), + paths: filterPosts.map(row => ({ params: { slug: row.slug } })), fallback: true } } diff --git a/themes/Hexo/LayoutBase.js b/themes/Hexo/LayoutBase.js index 96779c6f..dd186e06 100644 --- a/themes/Hexo/LayoutBase.js +++ b/themes/Hexo/LayoutBase.js @@ -6,6 +6,7 @@ import JumpToTopButton from './components/JumpToTopButton' import SideRight from './components/SideRight' import TopNav from './components/TopNav' import smoothscroll from 'smoothscroll-polyfill' +import FloatDarkModeButton from './components/FloatDarkModeButton' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -54,10 +55,11 @@ const LayoutBase = (props) => { {/* 右下角悬浮 */} -
-
- +
+
+ {floatSlot} +
diff --git a/themes/Hexo/LayoutSlug.js b/themes/Hexo/LayoutSlug.js index 901dc676..02642635 100644 --- a/themes/Hexo/LayoutSlug.js +++ b/themes/Hexo/LayoutSlug.js @@ -10,6 +10,7 @@ import 'prismjs/components/prism-typescript' import { useRef } from 'react' import ArticleDetail from './components/ArticleDetail' import HeaderArticle from './components/HeaderArticle' +import JumpToCommentButton from './components/JumpToCommentButton' import TocDrawer from './components/TocDrawer' import TocDrawerButton from './components/TocDrawerButton' import LayoutBase from './LayoutBase' @@ -31,18 +32,16 @@ export const LayoutSlug = props => { const drawerRight = useRef(null) const targetRef = typeof window !== 'undefined' ? document.getElementById('container') : null - const floatSlot = - post?.toc?.length > 1 - ? ( -
+ const floatSlot = <> + {post?.toc?.length > 1 &&
{ drawerRight?.current?.handleSwitchVisible() }} /> -
- ) - : null +
} + + return ( {
- + {post.title} @@ -22,7 +22,7 @@ const BlogPostCard = ({ post, showSummary }) => { @@ -49,7 +49,7 @@ const BlogPostCard = ({ post, showSummary }) => { - {post.category} + {post.category}
diff --git a/themes/Hexo/components/Collapse.js b/themes/Hexo/components/Collapse.js index 8af6f100..769ac602 100644 --- a/themes/Hexo/components/Collapse.js +++ b/themes/Hexo/components/Collapse.js @@ -5,6 +5,10 @@ const Collapse = props => { const collapseRef = useRef(null) const collapseSection = element => { const sectionHeight = element.scrollHeight + const currentHeight = element.style.height + if (currentHeight === '0px') { + return + } requestAnimationFrame(function () { element.style.height = sectionHeight + 'px' requestAnimationFrame(function () { diff --git a/themes/Hexo/components/FloatDarkModeButton.js b/themes/Hexo/components/FloatDarkModeButton.js new file mode 100644 index 00000000..196a7875 --- /dev/null +++ b/themes/Hexo/components/FloatDarkModeButton.js @@ -0,0 +1,30 @@ +import { useGlobal } from '@/lib/global' +import { saveDarkModeToCookies } from '@/lib/theme' +import CONFIG_HEXO from '../config_hexo' + +export default function FloatDarkModeButton () { + if (!CONFIG_HEXO.WIDGET_DARK_MODE) { + return <> + } + + const { isDarkMode, updateDarkMode } = useGlobal() + // 用户手动设置主题 + const handleChangeDarkMode = () => { + const newStatus = !isDarkMode + saveDarkModeToCookies(newStatus) + updateDarkMode(newStatus) + const htmlElement = document.getElementsByTagName('html')[0] + htmlElement.classList?.remove(newStatus ? 'light' : 'dark') + htmlElement.classList?.add(newStatus ? 'dark' : 'light') + } + + return ( +
+ +
+ ) +} diff --git a/themes/Hexo/components/Footer.js b/themes/Hexo/components/Footer.js index 50aacc75..c8612410 100644 --- a/themes/Hexo/components/Footer.js +++ b/themes/Hexo/components/Footer.js @@ -7,14 +7,15 @@ const Footer = ({ title }) => { const startYear = BLOG.SINCE && BLOG.SINCE !== currentYear && BLOG.SINCE + '-' return (