diff --git a/themes/next/Layout404.js b/themes/next/Layout404.js deleted file mode 100644 index f4b70dd9..00000000 --- a/themes/next/Layout404.js +++ /dev/null @@ -1,32 +0,0 @@ -import { useRouter } from 'next/router' -import LayoutBase from './LayoutBase' -import { useEffect } from 'react' -import { isBrowser } from '@/lib/utils' - -export const Layout404 = props => { - const router = useRouter() - useEffect(() => { - // 延时3秒如果加载失败就返回首页 - setTimeout(() => { - const article = isBrowser() && document.getElementById('article-wrapper') - if (!article) { - router.push('/').then(() => { - // console.log('找不到页面', router.asPath) - }) - } - }, 3000) - }, []) - - return -
-
-

404

-
-

页面无法加载,即将返回首页

-
-
-
-
-} -export default Layout404 diff --git a/themes/next/LayoutArchive.js b/themes/next/LayoutArchive.js deleted file mode 100644 index 29f6683c..00000000 --- a/themes/next/LayoutArchive.js +++ /dev/null @@ -1,35 +0,0 @@ -import React, { useEffect } from 'react' -import LayoutBase from './LayoutBase' -import BlogPostArchive from './components/BlogPostArchive' - -export const LayoutArchive = (props) => { - const { archivePosts } = props - - useEffect(() => { - const anchor = window.location.hash - if (anchor) { - setTimeout(() => { - const anchorElement = document.getElementById(anchor.substring(1)) - if (anchorElement) { - anchorElement.scrollIntoView({ block: 'start', behavior: 'smooth' }) - } - }, 300) - } - }, []) - - return ( - -
- {Object.keys(archivePosts).map(archiveTitle => ( - - ))} -
-
- ) -} - -export default LayoutArchive diff --git a/themes/next/LayoutBase.js b/themes/next/LayoutBase.js deleted file mode 100644 index 0f0f535d..00000000 --- a/themes/next/LayoutBase.js +++ /dev/null @@ -1,94 +0,0 @@ -import CommonHead from '@/components/CommonHead' -import FloatDarkModeButton from './components/FloatDarkModeButton' -import Footer from './components/Footer' -import JumpToBottomButton from './components/JumpToBottomButton' -import JumpToTopButton from './components/JumpToTopButton' -import LoadingCover from './components/LoadingCover' -import SideAreaLeft from './components/SideAreaLeft' -import SideAreaRight from './components/SideAreaRight' -import TopNav from './components/TopNav' -import { useGlobal } from '@/lib/global' -import { useEffect, useRef, useState } from 'react' -import CONFIG_NEXT from './config_next' -import Live2D from '@/components/Live2D' -import BLOG from '@/blog.config' - -/** - * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 - * @returns {JSX.Element} - * @constructor - */ -const LayoutBase = (props) => { - const { children, headerSlot, meta, sideBarSlot, floatSlot, rightAreaSlot, siteInfo } = props - const { onLoading } = useGlobal() - const targetRef = useRef(null) - const floatButtonGroup = useRef(null) - const leftAreaSlot = - - const [showRightFloat, switchShow] = useState(false) - const [percent, changePercent] = useState(0) // 页面阅读百分比 - - const scrollListener = () => { - const targetRef = document.getElementById('wrapper') - const clientHeight = targetRef?.clientHeight - const scrollY = window.pageYOffset - const fullHeight = clientHeight - window.outerHeight - let per = parseFloat(((scrollY / fullHeight * 100)).toFixed(0)) - if (per > 100) per = 100 - const shouldShow = scrollY > 100 && per > 0 - - if (shouldShow !== showRightFloat) { - switchShow(shouldShow) - } - changePercent(per) - } - - useEffect(() => { - // facebook messenger 插件需要调整右下角悬浮按钮的高度 - const fb = document.getElementsByClassName('fb-customerchat') - if (fb.length === 0) { - floatButtonGroup?.current?.classList.replace('bottom-24', 'bottom-12') - } else { - floatButtonGroup?.current?.classList.replace('bottom-12', 'bottom-24') - } - - document.addEventListener('scroll', scrollListener) - return () => document.removeEventListener('scroll', scrollListener) - }, [showRightFloat]) - - return (
- - - - - - <>{headerSlot} - -
- -
- {/* 左侧栏样式 */} - -
- {onLoading ? : <> {children} } -
- {/* 右侧栏样式 */} - { CONFIG_NEXT.RIGHT_BAR && } -
- - {/* 右下角悬浮 */} -
-
- - - - {floatSlot} -
-
- -
-
- ) -} - -export default LayoutBase diff --git a/themes/next/LayoutCategory.js b/themes/next/LayoutCategory.js deleted file mode 100644 index aaf07970..00000000 --- a/themes/next/LayoutCategory.js +++ /dev/null @@ -1,23 +0,0 @@ -import LayoutBase from './LayoutBase' -import StickyBar from './components/StickyBar' -import CategoryList from './components/CategoryList' -import BlogPostListScroll from './components/BlogPostListScroll' -import BlogPostListPage from './components/BlogPostListPage' -import BLOG from '@/blog.config' - -export const LayoutCategory = (props) => { - const { category, categoryOptions } = props - return - - - -
- {BLOG.POST_LIST_STYLE !== 'page' - ? - : - } -
-
-} - -export default LayoutCategory diff --git a/themes/next/LayoutCategoryIndex.js b/themes/next/LayoutCategoryIndex.js deleted file mode 100644 index ca7d992a..00000000 --- a/themes/next/LayoutCategoryIndex.js +++ /dev/null @@ -1,35 +0,0 @@ -import { useGlobal } from '@/lib/global' -import LayoutBase from './LayoutBase' -import Link from 'next/link' - -export const LayoutCategoryIndex = (props) => { - const { allPosts, categoryOptions } = props - const { locale } = useGlobal() - return ( - -
-
- {locale.COMMON.CATEGORY}: -
-
- {categoryOptions.map(category => { - return ( - -
- {category.name}({category.count}) -
- - ) - })} -
-
-
- ) -} - -export default LayoutCategoryIndex diff --git a/themes/next/LayoutIndex.js b/themes/next/LayoutIndex.js deleted file mode 100644 index 441a5660..00000000 --- a/themes/next/LayoutIndex.js +++ /dev/null @@ -1,26 +0,0 @@ -import LayoutBase from './LayoutBase' -import Header from './components/Header' -import LatestPostsGroup from './components/LatestPostsGroup' -import Card from './components/Card' -import BlogPostListScroll from './components/BlogPostListScroll' -import BlogPostListPage from './components/BlogPostListPage' -import CONFIG_NEXT from './config_next' -import BLOG from '@/blog.config' - -export const LayoutIndex = (props) => { - const { latestPosts } = props - const rightAreaSlot = CONFIG_NEXT.RIGHT_LATEST_POSTS && - return } - sideBarSlot={} - rightAreaSlot={rightAreaSlot} - {...props} - > - {BLOG.POST_LIST_STYLE !== 'page' - ? - : - } - -} - -export default LayoutIndex diff --git a/themes/next/LayoutPage.js b/themes/next/LayoutPage.js deleted file mode 100644 index 710392fd..00000000 --- a/themes/next/LayoutPage.js +++ /dev/null @@ -1,19 +0,0 @@ -import LayoutBase from './LayoutBase' -import LatestPostsGroup from './components/LatestPostsGroup' -import BlogPostListPage from './components/BlogPostListPage' -import CONFIG_NEXT from './config_next' - -export const LayoutPage = (props) => { - const { latestPosts } = props - return ( - } - rightAreaSlot={CONFIG_NEXT.RIGHT_LATEST_POSTS && } - {...props} - > - - - ) -} - -export default LayoutPage diff --git a/themes/next/LayoutSearch.js b/themes/next/LayoutSearch.js deleted file mode 100644 index 44a288d5..00000000 --- a/themes/next/LayoutSearch.js +++ /dev/null @@ -1,41 +0,0 @@ -import LayoutBase from './LayoutBase' -import StickyBar from './components/StickyBar' -import { useGlobal } from '@/lib/global' -import { isBrowser } from '@/lib/utils' -import BlogPostListScroll from './components/BlogPostListScroll' -import BlogPostListPage from './components/BlogPostListPage' -import Mark from 'mark.js' -import BLOG from '@/blog.config' - -export const LayoutSearch = (props) => { - const { locale } = useGlobal() - const { posts, keyword } = props - setTimeout(() => { - const container = isBrowser() && document.getElementById('posts-wrapper') - if (container && container.innerHTML) { - const re = new RegExp(keyword, 'gim') - const instance = new Mark(container) - instance.markRegExp(re, { - element: 'span', - className: 'text-red-500 border-b border-dashed' - }) - } - }, 200) - return ( - - -
- {' '} - {posts?.length} {locale.COMMON.RESULT_OF_SEARCH} -
-
-
- {BLOG.POST_LIST_STYLE !== 'page' - ? - : - }
-
- ) -} - -export default LayoutSearch diff --git a/themes/next/LayoutSlug.js b/themes/next/LayoutSlug.js deleted file mode 100644 index 4c5cb066..00000000 --- a/themes/next/LayoutSlug.js +++ /dev/null @@ -1,44 +0,0 @@ -import TocDrawerButton from './components/TocDrawerButton' -import LayoutBase from './LayoutBase' -import Card from './components/Card' -import LatestPostsGroup from './components/LatestPostsGroup' -import ArticleDetail from './components/ArticleDetail' -import TocDrawer from './components/TocDrawer' -import { useRef } from 'react' -import CONFIG_NEXT from './config_next' -import { ArticleLock } from './components/ArticleLock' -import { isBrowser } from '@/lib/utils' - -export const LayoutSlug = (props) => { - const { post, latestPosts, lock, validPassword } = props - const drawerRight = useRef(null) - const targetRef = isBrowser() ? document.getElementById('article-wrapper') : null - const floatSlot = post?.toc?.length > 1 - ?
{ - drawerRight?.current?.handleSwitchVisible() - }} />
- : null - - const rightAreaSlog = CONFIG_NEXT.RIGHT_LATEST_POSTS && - - return ( - - - {post && !lock && } - - {post && lock && } - - {/* 悬浮目录按钮 */} - {post &&
- -
} - -
- ) -} - -export default LayoutSlug diff --git a/themes/next/LayoutTag.js b/themes/next/LayoutTag.js deleted file mode 100644 index 9bf9b0c4..00000000 --- a/themes/next/LayoutTag.js +++ /dev/null @@ -1,24 +0,0 @@ -import LayoutBase from './LayoutBase' -import StickyBar from './components/StickyBar' -import TagList from './components/TagList' -import BlogPostListScroll from './components/BlogPostListScroll' -import BlogPostListPage from './components/BlogPostListPage' -import BLOG from '@/blog.config' - -export const LayoutTag = (props) => { - const { tagOptions, tag } = props - - return - - - -
- {BLOG.POST_LIST_STYLE !== 'page' - ? - : - } -
-
-} - -export default LayoutTag diff --git a/themes/next/LayoutTagIndex.js b/themes/next/LayoutTagIndex.js deleted file mode 100644 index a8e96067..00000000 --- a/themes/next/LayoutTagIndex.js +++ /dev/null @@ -1,20 +0,0 @@ -import { useGlobal } from '@/lib/global' -import LayoutBase from './LayoutBase' -import TagItem from './components/TagItem' - -export const LayoutTagIndex = (props) => { - const { tagOptions } = props - const { locale } = useGlobal() - return -
-
{locale.COMMON.TAGS}:
-
- { tagOptions.map(tag => { - return
- }) } -
-
-
-} - -export default LayoutTagIndex diff --git a/themes/next/components/BlogListBar.js b/themes/next/components/BlogListBar.js new file mode 100644 index 00000000..17f0cd4f --- /dev/null +++ b/themes/next/components/BlogListBar.js @@ -0,0 +1,29 @@ + +import CategoryList from './CategoryList' +import StickyBar from './StickyBar' +import TagList from './TagList' + +/** + * 博客列表上方嵌入 + * @param {*} props + * @returns + */ +export default function BlogListBar(props) { + const { tagOptions, tag } = props + const { category, categoryOptions } = props + if (tag) { + return ( + + + + ) + } else if (category) { + return ( + + + + ) + } else { + return <> + } +} diff --git a/themes/next/components/SideAreaLeft.js b/themes/next/components/SideAreaLeft.js index 83f79dc3..7ff48ada 100644 --- a/themes/next/components/SideAreaLeft.js +++ b/themes/next/components/SideAreaLeft.js @@ -9,6 +9,7 @@ import Logo from './Logo' import Card from './Card' import CONFIG_NEXT from '../config_next' import BLOG from '@/blog.config' +import Live2D from '@/components/Live2D' /** * 侧边平铺 @@ -66,9 +67,10 @@ const SideAreaLeft = props => { - {slot &&
+
{slot} -
} + +
diff --git a/themes/next/components/SideAreaRight.js b/themes/next/components/SideAreaRight.js index d3f7c5f2..01c36b49 100644 --- a/themes/next/components/SideAreaRight.js +++ b/themes/next/components/SideAreaRight.js @@ -9,6 +9,7 @@ import { useRouter } from 'next/router' import BLOG from '@/blog.config' import dynamic from 'next/dynamic' import Announcement from './Announcement' +import LatestPostsGroup from './LatestPostsGroup' const NextRecentComments = dynamic(() => import('./NextRecentComments')) /** @@ -22,7 +23,7 @@ const NextRecentComments = dynamic(() => import('./NextRecentComments')) * @constructor */ const SideAreaRight = (props) => { - const { tagOptions, currentTag, slot, categoryOptions, currentCategory, notice } = props + const { tagOptions, currentTag, slot, categoryOptions, currentCategory, notice, latestPosts } = props const { locale } = useGlobal() const router = useRouter() const announcementVisible = notice && Object.keys(notice).length > 0 @@ -48,6 +49,7 @@ const SideAreaRight = (props) => { } + {CONFIG_NEXT.RIGHT_LATEST_POSTS && } {slot} {/* 分类 */} diff --git a/themes/next/components/TocDrawerButton.js b/themes/next/components/TocDrawerButton.js index 3c92e09a..500ff563 100644 --- a/themes/next/components/TocDrawerButton.js +++ b/themes/next/components/TocDrawerButton.js @@ -10,13 +10,18 @@ import CONFIG_NEXT from '../config_next' * @constructor */ const TocDrawerButton = (props) => { + const { locale } = useGlobal() if (!CONFIG_NEXT.WIDGET_TOC) { return <> } - const { locale } = useGlobal() - return (
- -
) + if (props?.post?.toc?.length > 1) { + return ( +
+ +
+ ) + } + return <> } export default TocDrawerButton diff --git a/themes/next/components/TopNav.js b/themes/next/components/TopNav.js index 3644e875..87a9d569 100644 --- a/themes/next/components/TopNav.js +++ b/themes/next/components/TopNav.js @@ -91,37 +91,38 @@ const TopNav = (props) => { )} - return (
- + return ( +
+ - {/* 导航栏 */} -