{/* eslint-disable-next-line @next/next/no-img-element */}
-
+
+ {/*
- )}
+ )}
{/* 文章Title */}
+
+
*/}
@@ -111,10 +125,9 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n
{/* Notion文章主体 */}
- {blockMap && (
+ {post.blockMap && (
- {/* 推荐文章 */}
-
-
{/* 版权声明 */}
+ {/* 推荐文章 */}
+
+
{/* 标签列表 */}
{post.tagItems && (
@@ -165,7 +178,7 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n
{/* 评论互动 */}
-
{/* 宠物 */}
- {BLOG.showPet &&
+
@@ -177,7 +190,6 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n
-
+
-
+
{post.title}
-
{post.summary}
- -
+
+ {showSummary &&
- {post?.page_cover && (
+ {BLOG.home?.showPostCover && post?.page_cover && (
- + {post.summary} +
} + + {BLOG.home?.showPreview && post?.blockMap &&
+
+
}
+
+
+
+
+
+
+
@@ -50,4 +76,8 @@ const BlogPostCard = ({ post, tags }) => {
)
}
+const mapPageUrl = id => {
+ return 'https://www.notion.so/' + id.replace(/-/g, '')
+}
+
export default BlogPostCard
diff --git a/components/BlogPostListPage.js b/components/BlogPostListPage.js
index fe5fb6b0..4305f986 100644
--- a/components/BlogPostListPage.js
+++ b/components/BlogPostListPage.js
@@ -1,8 +1,6 @@
import BlogPostCard from '@/components/BlogPostCard'
-import Pagination from '@/components/Pagination'
+import PaginationNumber from './PaginationNumber'
import BLOG from '@/blog.config'
-
-import { useRouter } from 'next/router'
import BlogPostListEmpty from '@/components/BlogPostListEmpty'
/**
@@ -13,58 +11,23 @@ import BlogPostListEmpty from '@/components/BlogPostListEmpty'
* @returns {JSX.Element}
* @constructor
*/
-const BlogPostListPage = ({ page = 1, posts = [], tags }) => {
- let filteredBlogPosts = posts
+const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
+ const totalPage = Math.ceil(postCount / BLOG.postsPerPage)
- // 处理查询过滤 支持标签、关键词过滤
- let currentSearch = ''
- const router = useRouter()
- if (router.query && router.query.s) {
- currentSearch = router.query.s
- filteredBlogPosts = posts.filter(post => {
- const tagContent = post.tags ? post.tags.join(' ') : ''
- const searchContent = post.title + post.summary + tagContent + post.slug
- return searchContent.toLowerCase().includes(currentSearch.toLowerCase())
- })
- }
-
- // 处理分页
- const totalPages = Math.ceil(filteredBlogPosts.length / BLOG.postsPerPage)
- const postsToShow = filteredBlogPosts.slice(
- BLOG.postsPerPage * (page - 1),
- BLOG.postsPerPage * page
- )
- let showNext = false
- if (filteredBlogPosts) {
- const totalPosts = filteredBlogPosts.length
- showNext = page * BLOG.postsPerPage < totalPosts
- }
-
- if (!postsToShow || postsToShow.length === 0) {
+ if (!posts || posts.length === 0) {
return
} else {
- return
- {(!page || page === 1) && ()}
-
- {(page && page !== 1) && (
-
-
- )}
-
-
- {page && page !== 1 && (页 {page} / {totalPages})}
-
-
+ return (
+
} else {
- return
{/* 文章列表 */}
-
+ )
}
}
diff --git a/components/BlogPostListScroll.js b/components/BlogPostListScroll.js
index e272ed49..07fd9be1 100644
--- a/components/BlogPostListScroll.js
+++ b/components/BlogPostListScroll.js
@@ -1,10 +1,9 @@
-import BlogPostCard from '@/components/BlogPostCard'
import BLOG from '@/blog.config'
-
-import React, { useCallback, useEffect, useRef, useState } from 'react'
-import throttle from 'lodash.throttle'
+import BlogPostCard from '@/components/BlogPostCard'
import BlogPostListEmpty from '@/components/BlogPostListEmpty'
import { useGlobal } from '@/lib/global'
+import throttle from 'lodash.throttle'
+import React, { useCallback, useEffect, useRef, useState } from 'react'
/**
* 博客列表滚动分页
@@ -14,7 +13,7 @@ import { useGlobal } from '@/lib/global'
* @returns {JSX.Element}
* @constructor
*/
-const BlogPostListScroll = ({ posts = [], tags, currentSearch, currentCategory, currentTag }) => {
+const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = BLOG.home.showSummary }) => {
const postsPerPage = BLOG.postsPerPage
const [page, updatePage] = useState(1)
const postsToShow = getPostByPage(page, posts, postsPerPage)
@@ -53,12 +52,12 @@ const BlogPostListScroll = ({ posts = [], tags, currentSearch, currentCategory,
if (!postsToShow || postsToShow.length === 0) {
return
- {postsToShow.map(post => (
-
+
+
-
+ {posts.map(post => (
+
))}
-
-
+ return
{/* 文章列表 */}
-
+
{postsToShow.map(post => (
-
+
))}
diff --git a/components/CategoryList.js b/components/CategoryList.js
index 1f7ed378..cc876f82 100644
--- a/components/CategoryList.js
+++ b/components/CategoryList.js
@@ -1,7 +1,7 @@
import Link from 'next/link'
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
-import { faFolder, faFolderOpen, faThList } from '@fortawesome/free-solid-svg-icons'
+import { faFolder, faFolderOpen } from '@fortawesome/free-solid-svg-icons'
import { useGlobal } from '@/lib/global'
const CategoryList = ({ currentCategory, categories }) => {
@@ -11,7 +11,7 @@ const CategoryList = ({ currentCategory, categories }) => {
const { locale } = useGlobal()
return -
-
{locale.COMMON.CATEGORY}
+ - {locale.COMMON.CATEGORY} {Object.keys(categories).map(category => { const selected = category === currentCategory return ( diff --git a/components/Comment.js b/components/Comment.js index d41d7de4..ea747509 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -26,42 +26,46 @@ const Comment = ({ frontMatter }) => { const router = useRouter() const { theme } = useGlobal() - return
- {BLOG.comment.provider === 'gitalk' && ({title}
diff --git a/components/FloatDarkModeButton.js b/components/FloatDarkModeButton.js
index 3e3b246e..63ae157e 100644
--- a/components/FloatDarkModeButton.js
+++ b/components/FloatDarkModeButton.js
@@ -1,10 +1,13 @@
import { useEffect, useState } from 'react'
-import { useGlobal } from '@/lib/global'
+import { loadUserThemeFromCookies, saveTheme, useGlobal } from '@/lib/global'
import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
-import { loadUserThemeFromCookies, saveTheme } from '@/lib/theme'
+import BLOG from '@/blog.config'
export default function FloatDarkModeButton () {
+ if (!BLOG.widget?.showDarkMode) {
+ return <>>
+ }
const [show, switchShow] = useState(false)
const scrollListener = () => {
const scrollY = window.pageYOffset
@@ -14,9 +17,10 @@ export default function FloatDarkModeButton () {
}
}
useEffect(() => {
+ scrollListener()
document.addEventListener('scroll', scrollListener)
return () => document.removeEventListener('scroll', scrollListener)
- })
+ }, [show])
const { changeTheme } = useGlobal()
const userTheme = loadUserThemeFromCookies()
@@ -32,11 +36,12 @@ export default function FloatDarkModeButton () {
return (
-
-
)}
- {BLOG.comment.provider === 'utterances' && (
-
-
- )}
- {BLOG.comment.provider === 'cusdis' && (<>
-
-
-
+ return (
+ BLOG.comment.provider !== '' && (
+
+ )
+ )
}
export default Comment
diff --git a/components/CommonHead.js b/components/CommonHead.js
index eb18780b..784795a0 100644
--- a/components/CommonHead.js
+++ b/components/CommonHead.js
@@ -9,7 +9,7 @@ const CommonHead = ({ meta }) => {
const title = meta?.title || BLOG.title
const description = meta?.description || BLOG.description
const type = meta?.type || 'website'
- const keywords = meta?.tags || BLOG.seo.keywords
+ const keywords = meta?.tags || BLOG.keywords
return
+ {BLOG.comment.provider === 'gitalk' && (
- >)}
-
+
+
)}
+ {BLOG.comment.provider === 'utterances' && (
+
+
+ )}
+ {BLOG.comment.provider === 'cusdis' && (<>
+
+
+
+
+ >)}