diff --git a/components/ArticleDetail.js b/components/ArticleDetail.js index fe556c41..bff0cb21 100644 --- a/components/ArticleDetail.js +++ b/components/ArticleDetail.js @@ -38,9 +38,9 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n const date = formatDate(post?.date?.start_date || post.createdTime, locale.LOCALE) return (<> -
+
@@ -101,7 +101,7 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n
{/* Notion文章主体 */} -
+
{blockMap && ( -
+
{/* 文章内嵌广告 */} {/* 评论互动 */} -
+
diff --git a/components/BlogPostCard.js b/components/BlogPostCard.js index a7b0dd0f..9750d30f 100644 --- a/components/BlogPostCard.js +++ b/components/BlogPostCard.js @@ -9,7 +9,7 @@ import TagItemMini from './TagItemMini' const BlogPostCard = ({ post, tags }) => { return (
+ rounded-md w-full bg-white dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-gray-600'>
diff --git a/components/BlogPostListScroll.js b/components/BlogPostListScroll.js index d6337edf..e272ed49 100644 --- a/components/BlogPostListScroll.js +++ b/components/BlogPostListScroll.js @@ -56,7 +56,7 @@ const BlogPostListScroll = ({ posts = [], tags, currentSearch, currentCategory, return
{/* 文章列表 */} -
+
{postsToShow.map(post => ( ))} diff --git a/components/SideBar.js b/components/SideBar.js index 3ce2a3b2..bae915c1 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -54,7 +54,7 @@ const SideBar = ({ title, tags, currentTag, post, posts, categories, currentCate
{locale.COMMON.CATEGORY}
- + {locale.COMMON.MORE} diff --git a/components/StickyBar.js b/components/StickyBar.js index 18f10349..abbc25c9 100644 --- a/components/StickyBar.js +++ b/components/StickyBar.js @@ -1,3 +1,8 @@ +import throttle from 'lodash.throttle' +import { useCallback, useEffect } from 'react' + +let windowTop = 0 + /** * 标签组导航条,默认隐藏仅在移动端显示 * @param tags @@ -7,9 +12,31 @@ */ const StickyBar = ({ children }) => { if (!children) return <> + const scrollTrigger = useCallback(throttle(() => { + const scrollS = window.scrollY + if (scrollS >= windowTop && scrollS > 10) { + const stickyBar = document.querySelector('#sticky-bar') + stickyBar && stickyBar.classList.replace('top-14', 'top-0') + windowTop = scrollS + } else { + const stickyBar = document.querySelector('#sticky-bar') + stickyBar && stickyBar.classList.replace('top-0', 'top-14') + windowTop = scrollS + } + }, 200)) + + // 监听滚动 + useEffect(() => { + window.addEventListener('scroll', scrollTrigger) + scrollTrigger() + return () => { + window.removeEventListener('scroll', scrollTrigger) + } + }, []) + return (