From 6e30c9dd7ee3e5a3a0c8ea6011333375699a71d2 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sun, 12 Mar 2023 20:02:06 +0800 Subject: [PATCH] hexo\matery --- themes/hexo/LayoutBase.js | 4 +- themes/hexo/components/Header.js | 4 +- themes/matery/components/BlogPostCard.js | 18 ++++++-- themes/matery/components/Header.js | 50 ++++++++++++----------- themes/matery/components/HeaderArticle.js | 11 ++++- themes/matery/components/TopNav.js | 2 +- 6 files changed, 57 insertions(+), 32 deletions(-) diff --git a/themes/hexo/LayoutBase.js b/themes/hexo/LayoutBase.js index 80d06934..701daa71 100644 --- a/themes/hexo/LayoutBase.js +++ b/themes/hexo/LayoutBase.js @@ -65,14 +65,14 @@ const LayoutBase = props => { }, []) return ( -
+
{headerSlot} -
+
{ className="md:bg-fixed w-full h-screen bg-black text-white relative" >
-
diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js index b809c723..e7da2f17 100644 --- a/themes/matery/components/BlogPostCard.js +++ b/themes/matery/components/BlogPostCard.js @@ -3,6 +3,7 @@ import Link from 'next/link' import React from 'react' import TagItemMini from './TagItemMini' import CONFIG_MATERY from '../config_matery' +import Image from 'next/image' const BlogPostCard = ({ post, showSummary, siteInfo }) => { const showPreview = CONFIG_MATERY.POST_LIST_PREVIEW && post.blockMap @@ -14,7 +15,7 @@ const BlogPostCard = ({ post, showSummary, siteInfo }) => { return (
@@ -27,11 +28,22 @@ const BlogPostCard = ({ post, showSummary, siteInfo }) => {
{/* eslint-disable-next-line @next/next/no-img-element */} - {post.title} + /> */} +
+ {post.title} +
{post.title}
diff --git a/themes/matery/components/Header.js b/themes/matery/components/Header.js index 5ad30675..c7b7302c 100644 --- a/themes/matery/components/Header.js +++ b/themes/matery/components/Header.js @@ -1,3 +1,4 @@ +import Image from 'next/image' import { useEffect, useState } from 'react' import Typed from 'typed.js' import CONFIG_MATERY from '../config_matery' @@ -49,9 +50,9 @@ const Header = props => { } /** - * 吸附滚动,移动端关闭 - * @returns - */ + * 吸附滚动,移动端关闭 + * @returns + */ const scrollTrigger = () => { requestAnimationFrame(() => { if (screen.width <= 768) { @@ -76,7 +77,7 @@ const Header = props => { }) } - function updateHeaderHeight () { + function updateHeaderHeight() { requestAnimationFrame(() => { const wrapperElement = document.getElementById('wrapper') wrapperTop = wrapperElement?.offsetTop @@ -84,26 +85,29 @@ const Header = props => { } return ( - ) } diff --git a/themes/matery/components/HeaderArticle.js b/themes/matery/components/HeaderArticle.js index 6d8229c3..62317d06 100644 --- a/themes/matery/components/HeaderArticle.js +++ b/themes/matery/components/HeaderArticle.js @@ -1,3 +1,5 @@ +import Image from 'next/image' + export default function HeaderArticle({ post, siteInfo }) { const headerImage = post?.page_cover ? post?.page_cover : siteInfo?.pageCover const title = post?.title @@ -9,11 +11,16 @@ export default function HeaderArticle({ post, siteInfo }) { data-aos-anchor-placement="top-center" id='header' className="flex h-96 justify-center align-middle items-center w-full relative duration-200 bg-black"> {/* eslint-disable-next-line @next/next/no-img-element */} - {title} + /> */} + {title} {title}
) diff --git a/themes/matery/components/TopNav.js b/themes/matery/components/TopNav.js index 47b485a8..73086b76 100644 --- a/themes/matery/components/TopNav.js +++ b/themes/matery/components/TopNav.js @@ -27,7 +27,7 @@ const TopNav = props => { const scrollS = window.scrollY const nav = document.querySelector('#sticky-nav') const header = document.querySelector('#header') - const showNav = scrollS <= windowTop || scrollS < 5 // 非首页无大图时影藏顶部 滚动条置顶时隐藏 + const showNav = scrollS <= windowTop || scrollS < 5 || (header && scrollS <= header.clientHeight * 2)// 非首页无大图时影藏顶部 滚动条置顶时隐藏// 非首页无大图时影藏顶部 滚动条置顶时隐藏 // 是否将导航栏透明 const navTransparent = header && scrollS < 300 // 透明导航条的条件