diff --git a/themes/heo/components/BlogPostCard.js b/themes/heo/components/BlogPostCard.js index 648ce49e..e1e8edde 100644 --- a/themes/heo/components/BlogPostCard.js +++ b/themes/heo/components/BlogPostCard.js @@ -14,17 +14,16 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { // const delay = (index % 2) * 200 return ( -
{/* 文字内容 */} @@ -32,7 +31,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { {/* 图片封面 */} {showPageCover && ( -
+
diff --git a/themes/heo/components/BlogPostListPage.js b/themes/heo/components/BlogPostListPage.js index 92008f83..336e7714 100644 --- a/themes/heo/components/BlogPostListPage.js +++ b/themes/heo/components/BlogPostListPage.js @@ -20,7 +20,7 @@ const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { return (
{/* 文章列表 */} -
+
{posts?.map(post => ( ))} diff --git a/themes/heo/components/CategoryBar.js b/themes/heo/components/CategoryBar.js new file mode 100644 index 00000000..53e3af73 --- /dev/null +++ b/themes/heo/components/CategoryBar.js @@ -0,0 +1,9 @@ + +/** + * 博客列表上方嵌入条 + * @param {*} props + * @returns + */ +export default function CategoryBar(props) { + return
+} diff --git a/themes/heo/components/Footer.js b/themes/heo/components/Footer.js index f67b53f2..531c1ce8 100644 --- a/themes/heo/components/Footer.js +++ b/themes/heo/components/Footer.js @@ -1,11 +1,12 @@ import React from 'react' import BLOG from '@/blog.config' +import SocialButton from './SocialButton' // import DarkModeButton from '@/components/DarkModeButton' const Footer = ({ title }) => { const d = new Date() const currentYear = d.getFullYear() - const copyrightDate = (function() { + const copyrightDate = (function () { if (Number.isInteger(BLOG.SINCE) && BLOG.SINCE < currentYear) { return BLOG.SINCE + '-' + currentYear } @@ -13,23 +14,36 @@ const Footer = ({ title }) => { })() return ( - ) } diff --git a/themes/heo/components/Header.js b/themes/heo/components/Header.js index 76e86c25..052815ae 100644 --- a/themes/heo/components/Header.js +++ b/themes/heo/components/Header.js @@ -1,82 +1,82 @@ -// import Image from 'next/image' -import { useEffect, useState } from 'react' -import Typed from 'typed.js' -import CONFIG from '../config' -import NavButtonGroup from './NavButtonGroup' -import { useGlobal } from '@/lib/global' -import BLOG from '@/blog.config' +import { useCallback, useEffect, useRef, useState } from 'react' +import Logo from './Logo' +import SearchDrawer from './SearchDrawer' -let wrapperTop = 0 +import { MenuListTop } from './MenuListTop' +import throttle from 'lodash.throttle' +import SideBar from './SideBar' +import SideBarDrawer from './SideBarDrawer' /** - * 顶部全屏大图 + * 顶部导航 + * @param {*} param0 * @returns */ -const Hero = props => { - const [typed, changeType] = useState() - const { siteInfo } = props - const { locale } = useGlobal() - const scrollToWrapper = () => { - window.scrollTo({ top: wrapperTop, behavior: 'smooth' }) +const Header = props => { + const searchDrawer = useRef() + + const [isOpen, changeShow] = useState(false) + const [headerBgShow, setHeaderBgShow] = useState(false) + + const toggleMenuOpen = () => { + changeShow(!isOpen) } + + const toggleSideBarClose = () => { + changeShow(false) + } + + // 监听滚动 useEffect(() => { - updateHeaderHeight() - - if (!typed && window && document.getElementById('typed')) { - changeType( - new Typed('#typed', { - strings: BLOG.GREETING_WORDS.split(','), - typeSpeed: 200, - backSpeed: 100, - backDelay: 400, - showCursor: true, - smartBackspace: true - }) - ) - } - - window.addEventListener('resize', updateHeaderHeight) + scrollTrigger() + window.addEventListener('scroll', scrollTrigger) return () => { - window.removeEventListener('resize', updateHeaderHeight) + window.removeEventListener('scroll', scrollTrigger) } - }) + }, []) - function updateHeaderHeight() { - requestAnimationFrame(() => { - const wrapperElement = document.getElementById('wrapper') - wrapperTop = wrapperElement?.offsetTop - }) - } + const throttleMs = 200 - return ( - - ) + {/* 折叠侧边栏 */} + + + +
) } -export default Hero +export default Header diff --git a/themes/heo/components/Hero.js b/themes/heo/components/Hero.js new file mode 100644 index 00000000..d14d6955 --- /dev/null +++ b/themes/heo/components/Hero.js @@ -0,0 +1,29 @@ +// import Image from 'next/image' + +/** + * 顶部全屏大图 + * @returns + */ +const Hero = props => { + return ( +
+ + +
+
+ + +
+
+
+
+
+ +
+
+ +
+ ) +} + +export default Hero diff --git a/themes/heo/components/Logo.js b/themes/heo/components/Logo.js index 2dd392b7..71c264f4 100644 --- a/themes/heo/components/Logo.js +++ b/themes/heo/components/Logo.js @@ -6,8 +6,10 @@ const Logo = props => { const { siteInfo } = props return ( -
-
{siteInfo?.title || BLOG.TITLE}
+
+ {/* eslint-disable-next-line @next/next/no-img-element */} + {BLOG.AUTHOR} +
{siteInfo?.title || BLOG.TITLE}
) diff --git a/themes/heo/components/HeaderArticle.js b/themes/heo/components/PostHeader.js similarity index 98% rename from themes/heo/components/HeaderArticle.js rename to themes/heo/components/PostHeader.js index b5384a1f..e383672b 100644 --- a/themes/heo/components/HeaderArticle.js +++ b/themes/heo/components/PostHeader.js @@ -4,7 +4,7 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import NotionIcon from '@/components/NotionIcon' -export default function HeaderArticle({ post, siteInfo }) { +export default function PostHeader({ post, siteInfo }) { const { locale } = useGlobal() if (!post) { diff --git a/themes/heo/components/SideRight.js b/themes/heo/components/SideRight.js index 570bf32f..a08409e9 100644 --- a/themes/heo/components/SideRight.js +++ b/themes/heo/components/SideRight.js @@ -1,18 +1,11 @@ import Card from './Card' -import CategoryGroup from './CategoryGroup' -import LatestPostsGroup from './LatestPostsGroup' import TagGroups from './TagGroups' import Catalog from './Catalog' import { InfoCard } from './InfoCard' -import { AnalyticsCard } from './AnalyticsCard' -import CONFIG from '../config' -import BLOG from '@/blog.config' import dynamic from 'next/dynamic' import Announcement from './Announcement' -import { useGlobal } from '@/lib/global' import Live2D from '@/components/Live2D' -const HexoRecentComments = dynamic(() => import('./HexoRecentComments')) const FaceBookPage = dynamic( () => { let facebook = <> @@ -33,50 +26,36 @@ const FaceBookPage = dynamic( */ export default function SideRight(props) { const { - post, currentCategory, categories, latestPosts, tags, - currentTag, showCategory, showTag, rightAreaSlot, notice + post, tagOptions, + currentTag, rightAreaSlot, notice } = props - const { locale } = useGlobal() + console.log('props', props) return ( -
- - {CONFIG.WIDGET_ANALYTICS && } +
- {showCategory && ( - -
- {locale.COMMON.CATEGORY} -
- -
- )} - {showTag && ( - - - - )} - {CONFIG.WIDGET_LATEST_POSTS && latestPosts && latestPosts.length > 0 && - - } + - + +
Join Us
+
- {BLOG.COMMENT_WALINE_SERVER_URL && BLOG.COMMENT_WALINE_RECENT && } + + + -
- {post && post.toc && post.toc.length > 1 && - - } + - {rightAreaSlot} - - -
+
+ {post && post.toc && post.toc.length > 1 && + + } -
+ {rightAreaSlot} + + +
+ +
) } diff --git a/themes/heo/components/SlotBar.js b/themes/heo/components/SlotBar.js deleted file mode 100644 index 2cd6244b..00000000 --- a/themes/heo/components/SlotBar.js +++ /dev/null @@ -1,24 +0,0 @@ -import Link from 'next/link' - -/** - * 博客列表上方嵌入条 - * @param {*} props - * @returns - */ -export default function SlotBar(props) { - const { tag, category } = props - - if (tag) { - return
- -
#{tag.name + (tag.count ? `(${tag.count})` : '')}
- -
- } else if (category) { - return
- {category} -
- } - return <> -} diff --git a/themes/heo/components/SocialButton.js b/themes/heo/components/SocialButton.js index e3305cee..1d9d1d35 100644 --- a/themes/heo/components/SocialButton.js +++ b/themes/heo/components/SocialButton.js @@ -8,7 +8,7 @@ import React from 'react' */ const SocialButton = () => { return
-
+
{BLOG.CONTACT_GITHUB && } diff --git a/themes/heo/components/TopNav.js b/themes/heo/components/TopNav.js deleted file mode 100644 index 252ce8a0..00000000 --- a/themes/heo/components/TopNav.js +++ /dev/null @@ -1,159 +0,0 @@ -import { useGlobal } from '@/lib/global' -import Link from 'next/link' -import { useCallback, useEffect, useRef, useState } from 'react' -import CategoryGroup from './CategoryGroup' -import Logo from './Logo' -import SearchDrawer from './SearchDrawer' -import TagGroups from './TagGroups' -import { MenuListTop } from './MenuListTop' -import { useRouter } from 'next/router' -import throttle from 'lodash.throttle' -import SideBar from './SideBar' -import SideBarDrawer from './SideBarDrawer' - -let windowTop = 0 - -/** - * 顶部导航 - * @param {*} param0 - * @returns - */ -const TopNav = props => { - const searchDrawer = useRef() - const { tags, currentTag, categories, currentCategory } = props - const { locale } = useGlobal() - const { isDarkMode } = useGlobal() - const router = useRouter() - - const [isOpen, changeShow] = useState(false) - - const toggleMenuOpen = () => { - changeShow(!isOpen) - } - - const toggleSideBarClose = () => { - changeShow(false) - } - - // 监听滚动 - useEffect(() => { - scrollTrigger() - window.addEventListener('scroll', scrollTrigger) - return () => { - window.removeEventListener('scroll', scrollTrigger) - } - }, []) - - const throttleMs = 200 - - const scrollTrigger = useCallback(throttle(() => { - const scrollS = window.scrollY - const nav = document.querySelector('#sticky-nav') - const header = document.querySelector('#header') - // 是否将导航栏透明 - const navTransparent = (scrollS < document.documentElement.clientHeight - 12 && router.route === '/') || scrollS < 300 // 透明导航条的条件 - - if (header && navTransparent) { - nav && nav.classList.replace('bg-white', 'bg-none') - nav && nav.classList.replace('text-black', 'text-white') - nav && nav.classList.replace('border', 'border-transparent') - nav && nav.classList.replace('drop-shadow-md', 'shadow-none') - nav && nav.classList.replace('dark:bg-hexo-black-gray', 'transparent') - } else { - nav && nav.classList.replace('bg-none', 'bg-white') - nav && nav.classList.replace('text-white', 'text-black') - nav && nav.classList.replace('border-transparent', 'border') - nav && nav.classList.replace('shadow-none', 'drop-shadow-md') - nav && nav.classList.replace('transparent', 'dark:bg-hexo-black-gray') - } - - const showNav = scrollS <= windowTop || scrollS < 5 || (header && scrollS <= header.clientHeight)// 非首页无大图时影藏顶部 滚动条置顶时隐藏 - if (!showNav) { - nav && nav.classList.replace('top-0', '-top-20') - windowTop = scrollS - } else { - nav && nav.classList.replace('-top-20', 'top-0') - windowTop = scrollS - } - navDarkMode() - }, throttleMs) - ) - - const navDarkMode = () => { - const nav = document.getElementById('sticky-nav') - const header = document.querySelector('#header') - if (!isDarkMode && nav && header) { - if (window.scrollY < header.clientHeight) { - nav?.classList?.add('dark') - } else { - nav?.classList?.remove('dark') - } - } - } - - const searchDrawerSlot = <> - {categories && ( -
-
-
{locale.COMMON.CATEGORY}
- - - {locale.COMMON.MORE} - - -
- -
- )} - - {tags && ( -
-
-
{locale.COMMON.TAGS}
- - - {locale.COMMON.MORE} - - -
-
- -
-
- )} - - - return (
- - - {/* 导航栏 */} - - - {/* 折叠侧边栏 */} - - - -
) -} - -export default TopNav diff --git a/themes/heo/index.js b/themes/heo/index.js index a35bbded..d0087aa9 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -4,21 +4,20 @@ import CommonHead from '@/components/CommonHead' import { useEffect, useRef } from 'react' import Footer from './components/Footer' import SideRight from './components/SideRight' -import TopNav from './components/TopNav' +import Header from './components/Header' import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { isBrowser, loadExternalResource } from '@/lib/utils' import BlogPostListPage from './components/BlogPostListPage' import BlogPostListScroll from './components/BlogPostListScroll' -import Hero from './components/Header' +import Hero from './components/Hero' import { useRouter } from 'next/router' import Mark from 'mark.js' import Card from './components/Card' -import RightFloatArea from './components/RightFloatArea' import SearchNav from './components/SearchNav' import BlogPostArchive from './components/BlogPostArchive' import { ArticleLock } from './components/ArticleLock' -import HeaderArticle from './components/HeaderArticle' +import PostHeader from './components/PostHeader' import JumpToCommentButton from './components/JumpToCommentButton' import TocDrawer from './components/TocDrawer' import TocDrawerButton from './components/TocDrawerButton' @@ -30,7 +29,7 @@ import ArticleRecommend from './components/ArticleRecommend' import ShareBar from '@/components/ShareBar' import TagItemMini from './components/TagItemMini' import Link from 'next/link' -import SlotBar from './components/SlotBar' +import CategoryBar from './components/CategoryBar' import { Transition } from '@headlessui/react' /** @@ -40,7 +39,7 @@ import { Transition } from '@headlessui/react' * @constructor */ const LayoutBase = props => { - const { children, headerSlot, floatSlot, slotTop, meta, siteInfo, className } = props + const { children, headerSlot, slotTop, meta, siteInfo, className } = props const { onLoading } = useGlobal() // 加载主题样式 @@ -49,14 +48,14 @@ const LayoutBase = props => { } return ( -
+
{/* 网页SEO */} {/* 顶部导航 */} - +
- {/* 顶部嵌入 */} + {/* 顶部嵌入 首页放hero,文章页放大图 */} { {/* 主区块 */} -
+
-
+
{
- {/* 悬浮菜单 */} - - {/* 页脚 */}
@@ -116,7 +112,7 @@ const LayoutBase = props => { */ const LayoutIndex = (props) => { const headerSlot = CONFIG.HOME_BANNER_ENABLE && - return + return } /** @@ -125,8 +121,8 @@ const LayoutIndex = (props) => { * @returns */ const LayoutPostList = (props) => { - return - + return + {BLOG.POST_LIST_STYLE === 'page' ? : } } @@ -213,7 +209,7 @@ const LayoutSlug = props => { return ( - } showCategory={false} showTag={false} floatSlot={floatSlot} > + } showCategory={false} showTag={false} floatSlot={floatSlot} >
{lock && } diff --git a/themes/hexo/components/Header.js b/themes/hexo/components/Hero.js similarity index 100% rename from themes/hexo/components/Header.js rename to themes/hexo/components/Hero.js diff --git a/themes/hexo/components/HeaderArticle.js b/themes/hexo/components/PostHeader.js similarity index 98% rename from themes/hexo/components/HeaderArticle.js rename to themes/hexo/components/PostHeader.js index b5384a1f..e383672b 100644 --- a/themes/hexo/components/HeaderArticle.js +++ b/themes/hexo/components/PostHeader.js @@ -4,7 +4,7 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import NotionIcon from '@/components/NotionIcon' -export default function HeaderArticle({ post, siteInfo }) { +export default function PostHeader({ post, siteInfo }) { const { locale } = useGlobal() if (!post) { diff --git a/themes/hexo/index.js b/themes/hexo/index.js index dd4e8aa5..603c8b75 100644 --- a/themes/hexo/index.js +++ b/themes/hexo/index.js @@ -10,7 +10,7 @@ import BLOG from '@/blog.config' import { isBrowser, loadExternalResource } from '@/lib/utils' import BlogPostListPage from './components/BlogPostListPage' import BlogPostListScroll from './components/BlogPostListScroll' -import Hero from './components/Header' +import Hero from './components/Hero' import { useRouter } from 'next/router' import Mark from 'mark.js' import Card from './components/Card' @@ -18,7 +18,7 @@ import RightFloatArea from './components/RightFloatArea' import SearchNav from './components/SearchNav' import BlogPostArchive from './components/BlogPostArchive' import { ArticleLock } from './components/ArticleLock' -import HeaderArticle from './components/HeaderArticle' +import PostHeader from './components/PostHeader' import JumpToCommentButton from './components/JumpToCommentButton' import TocDrawer from './components/TocDrawer' import TocDrawerButton from './components/TocDrawerButton' @@ -213,7 +213,7 @@ const LayoutSlug = props => { return ( - } showCategory={false} showTag={false} floatSlot={floatSlot} > + } showCategory={false} showTag={false} floatSlot={floatSlot} >
{lock && } diff --git a/themes/matery/components/HeaderArticle.js b/themes/matery/components/PostHeader.js similarity index 91% rename from themes/matery/components/HeaderArticle.js rename to themes/matery/components/PostHeader.js index 3b9c85a1..dd58bd5f 100644 --- a/themes/matery/components/HeaderArticle.js +++ b/themes/matery/components/PostHeader.js @@ -1,6 +1,9 @@ import Image from 'next/image' -export default function HeaderArticle({ post, siteInfo }) { +/** + * 文章背景图 + */ +export default function PostHeader({ post, siteInfo }) { const headerImage = post?.pageCoverThumbnail ? post?.pageCoverThumbnail : siteInfo?.pageCover const title = post?.title return ( diff --git a/themes/matery/index.js b/themes/matery/index.js index 05744dcd..7c30aefe 100644 --- a/themes/matery/index.js +++ b/themes/matery/index.js @@ -17,7 +17,7 @@ import Hero from './components/Hero' import Announcement from './components/Announcement' import CatalogWrapper from './components/CatalogWrapper' import TagItemMiddle from './components/TagItemMiddle' -import HeaderArticle from './components/HeaderArticle' +import PostHeader from './components/PostHeader' import Link from 'next/link' import ArticleAdjacent from './components/ArticleAdjacent' import Comment from '@/components/Comment' @@ -177,7 +177,7 @@ const LayoutSearch = props => { */ const LayoutArchive = (props) => { const { archivePosts } = props - return } > + return } >
{Object.keys(archivePosts).map(archiveTitle => ( @@ -200,7 +200,7 @@ const LayoutArchive = (props) => { const LayoutSlug = props => { const { post, lock, validPassword } = props - return (} showCategory={false} showTag={false} floatRightBottom={}> + return (} showCategory={false} showTag={false} floatRightBottom={}>
@@ -310,7 +310,7 @@ const LayoutCategoryIndex = props => { const { categoryOptions } = props return ( - } > + } >
@@ -340,7 +340,7 @@ const LayoutTagIndex = props => { const { tagOptions } = props const { locale } = useGlobal() return ( - } > + } >
diff --git a/themes/nobelium/components/BlogPost.js b/themes/nobelium/components/BlogPost.js index 48652cf6..91ad3bd4 100644 --- a/themes/nobelium/components/BlogPost.js +++ b/themes/nobelium/components/BlogPost.js @@ -23,7 +23,7 @@ const BlogPost = ({ post }) => { ) - ); + ) } export default BlogPost