diff --git a/.env.local b/.env.local index 5f3e2582..4b00e7e6 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=3.9.1 +NEXT_PUBLIC_VERSION=3.9.2 diff --git a/components/FlutteringRibbon.js b/components/FlutteringRibbon.js index 2eb817e4..a615d533 100644 --- a/components/FlutteringRibbon.js +++ b/components/FlutteringRibbon.js @@ -136,6 +136,7 @@ function createFlutteringRibbon() { (this._canvas.style.width = '100%'), (this._canvas.style.height = '100%'), (this._canvas.style['z-index'] = '0'), + (this._canvas.style['pointer-events'] = 'none'), this._onResize(), (this._context = this._canvas.getContext('2d')), this._context.clearRect(0, 0, this._width, this._height), diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 80444cdb..f865d4ed 100644 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -27,11 +27,15 @@ export async function getGlobalNotionData({ // 获取Notion数据 const notionPageData = deepClone(await getNotionPageData({ pageId, from })) delete notionPageData.block - delete notionPageData.collection - delete notionPageData.collectionQuery delete notionPageData.schema delete notionPageData.rawMetadata delete notionPageData.pageIds + delete notionPageData.viewIds + delete notionPageData.collection + delete notionPageData.collectionQuery + delete notionPageData.collectionId + delete notionPageData.collectionView + console.log(notionPageData) return notionPageData } @@ -192,12 +196,10 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { const collectionQuery = pageRecordMap.collection_query const collectionView = pageRecordMap.collection_view const schema = collection?.schema - const tagOptions = getTagOptions(schema) - const categoryOptions = getCategoryOptions(schema) + const viewIds = rawMetadata?.view_ids const collectionData = [] const pageIds = getAllPageIds(collectionQuery, collectionId, collectionView, viewIds) - const siteInfo = getBlogInfo({ collection, block }) if (pageIds?.length === 0) { console.error('获取到的文章列表为空,请检查notion模板', collectionQuery, collection, collectionView, viewIds, pageRecordMap) } @@ -207,15 +209,12 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { if (!value) { continue } - const properties = (await getPageProperties(id, block, schema, null, tagOptions, siteInfo)) || null + const properties = (await getPageProperties(id, block, schema, null, getTagOptions(schema))) || null if (properties) { collectionData.push(properties) } } - // 获取page作为自定义菜单 - const customNav = getCustomNav({ allPages: collectionData.filter(post => post.type === 'Page' && post.status === 'Published') }) - // 文章计数 let postCount = 0 const allPages = collectionData.filter(post => { @@ -238,8 +237,10 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { }) } - const categories = getAllCategories({ allPages, categoryOptions, sliceCount: BLOG.PREVIEW_CATEGORY_COUNT }) - const tags = getAllTags({ allPages, sliceCount: BLOG.PREVIEW_TAG_COUNT, tagOptions }) + const categoryOptions = getAllCategories({ allPages, categoryOptions: getCategoryOptions(schema), sliceCount: BLOG.PREVIEW_CATEGORY_COUNT }) + const tagOptions = getAllTags({ allPages, sliceCount: BLOG.PREVIEW_TAG_COUNT, tagOptions: getTagOptions(schema) }) + const siteInfo = getBlogInfo({ collection, block }) + const customNav = getCustomNav({ allPages: collectionData.filter(post => post.type === 'Page' && post.status === 'Published') }) const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 5 }) return { @@ -258,8 +259,6 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { customNav, postCount, pageIds, - categories, - tags, latestPosts } } diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js index 6079ce51..b498fd82 100644 --- a/lib/notion/getPageProperties.js +++ b/lib/notion/getPageProperties.js @@ -6,7 +6,7 @@ import { defaultMapImageUrl } from 'react-notion-x' // import { createHash } from 'crypto' import md5 from 'js-md5' -export default async function getPageProperties(id, block, schema, authToken, tagOptions, siteInfo) { +export default async function getPageProperties(id, block, schema, authToken, tagOptions) { const rawProperties = Object.entries(block?.[id]?.value?.properties || []) const excludeProperties = ['date', 'select', 'multi_select', 'person'] const value = block[id]?.value @@ -89,7 +89,7 @@ export default async function getPageProperties(id, block, schema, authToken, ta properties.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG) properties.fullWidth = value.format?.page_full_width ?? false properties.pageIcon = getImageUrl(block[id].value?.format?.page_icon, block[id].value) ?? '' - properties.page_cover = getImageUrl(block[id].value?.format?.page_cover, block[id].value) ?? siteInfo?.pageCover + properties.page_cover = getImageUrl(block[id].value?.format?.page_cover, block[id].value) ?? '' properties.content = value.content ?? [] properties.password = properties.password ? md5(properties.slug + properties.password) diff --git a/package.json b/package.json index 456eadf4..b23b67f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "3.9.1", + "version": "3.9.2", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": { diff --git a/pages/category/[category]/index.js b/pages/category/[category]/index.js index eaf8436a..583a69ab 100644 --- a/pages/category/[category]/index.js +++ b/pages/category/[category]/index.js @@ -58,10 +58,10 @@ export async function getStaticProps({ params: { category } }) { export async function getStaticPaths() { const from = 'category-paths' - const { categories } = await getGlobalNotionData({ from }) + const { categoryOptions } = await getGlobalNotionData({ from }) return { - paths: Object.keys(categories).map(category => ({ - params: { category: categories[category]?.name } + paths: Object.keys(categoryOptions).map(category => ({ + params: { category: categoryOptions[category]?.name } })), fallback: true } diff --git a/pages/category/[category]/page/[page].js b/pages/category/[category]/page/[page].js index 06b66a21..f01ae27a 100644 --- a/pages/category/[category]/page/[page].js +++ b/pages/category/[category]/page/[page].js @@ -53,10 +53,10 @@ export async function getStaticProps({ params: { category, page } }) { export async function getStaticPaths() { const from = 'category-paths' - const { categories, allPages } = await getGlobalNotionData({ from }) + const { categoryOptions, allPages } = await getGlobalNotionData({ from }) const paths = [] - categories?.forEach(category => { + categoryOptions?.forEach(category => { // 过滤状态类型 const categoryPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published').filter(post => post && post.category && post.category.includes(category.name)) // 处理文章页数 diff --git a/pages/category/index.js b/pages/category/index.js index 24653c8c..b310c188 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -2,7 +2,6 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' import { useGlobal } from '@/lib/global' import * as ThemeMap from '@/themes' -import { getAllCategories } from '@/lib/notion/getAllCategories' import BLOG from '@/blog.config' /** @@ -27,8 +26,6 @@ export default function Category(props) { export async function getStaticProps() { const props = await getGlobalNotionData({ from: 'category-index-props' }) - props.categories = getAllCategories({ allPages: props.allPages, categoryOptions: props.categoryOptions, sliceCount: 0 }) - delete props.categoryOptions delete props.allPages return { props, diff --git a/pages/tag/[tag]/index.js b/pages/tag/[tag]/index.js index 593bf555..f633c94f 100644 --- a/pages/tag/[tag]/index.js +++ b/pages/tag/[tag]/index.js @@ -63,8 +63,8 @@ function getTagNames(tags) { export async function getStaticPaths() { const from = 'tag-static-path' - const { tags } = await getGlobalNotionData({ from }) - const tagNames = getTagNames(tags) + const { tagOptions } = await getGlobalNotionData({ from }) + const tagNames = getTagNames(tagOptions) return { paths: Object.keys(tagNames).map(index => ({ diff --git a/pages/tag/[tag]/page/[page].js b/pages/tag/[tag]/page/[page].js index a21e46b4..788473b9 100644 --- a/pages/tag/[tag]/page/[page].js +++ b/pages/tag/[tag]/page/[page].js @@ -44,9 +44,9 @@ export async function getStaticProps({ params: { tag, page } }) { export async function getStaticPaths() { const from = 'tag-page-static-path' - const { tags, allPages } = await getGlobalNotionData({ from }) + const { tagOptions, allPages } = await getGlobalNotionData({ from }) const paths = [] - tags?.forEach(tag => { + tagOptions?.forEach(tag => { // 过滤状态类型 const tagPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published').filter(post => post && post.tags && post.tags.includes(tag.name)) // 处理文章页数 diff --git a/pages/tag/index.js b/pages/tag/index.js index cddba52a..e9263668 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -2,7 +2,6 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' import { useGlobal } from '@/lib/global' import * as ThemeMap from '@/themes' -import { getAllTags } from '@/lib/notion' import BLOG from '@/blog.config' /** @@ -28,8 +27,6 @@ const TagIndex = props => { export async function getStaticProps() { const from = 'tag-index-props' const props = await getGlobalNotionData({ from }) - props.tags = getAllTags({ allPages: props.allPages, sliceCount: 0, tagOptions: props.tagOptions }) - delete props.tagOptions delete props.allPages return { props, diff --git a/themes/example/LayoutCategoryIndex.js b/themes/example/LayoutCategoryIndex.js index 1230c20f..a4c19033 100644 --- a/themes/example/LayoutCategoryIndex.js +++ b/themes/example/LayoutCategoryIndex.js @@ -1,13 +1,12 @@ import Link from 'next/link' import LayoutBase from './LayoutBase' -export const LayoutCategoryIndex = (props) => { - const { categories } = props - +export const LayoutCategoryIndex = props => { + const { categoryOptions } = props return (
- {categories && categories.map(category => { + {categoryOptions?.map(category => { return ( { - const { tags } = props + const { tagOptions } = props return (
- {tags.map(tag => { + {tagOptions.map(tag => { return (
{
- ); + ) })}
- ); + ) } diff --git a/themes/example/components/BlogListPage.js b/themes/example/components/BlogListPage.js index 390bf90a..ce643eb8 100644 --- a/themes/example/components/BlogListPage.js +++ b/themes/example/components/BlogListPage.js @@ -15,6 +15,7 @@ export const BlogListPage = props => { const showNext = page < totalPage const pagePrefix = router.asPath.replace(/\/page\/[1-9]\d*/, '').replace(/\/$/, '') + console.log('p', posts) return (
@@ -32,7 +33,7 @@ export const BlogListPage = props => {
by {BLOG.AUTHOR} on {p.date?.start_date || p.createdTime} | - {p.category} + {p.category} {/* | */} {/* 2 Comments */}
@@ -65,5 +66,5 @@ export const BlogListPage = props => {
- ); + ) } diff --git a/themes/example/components/SideBar.js b/themes/example/components/SideBar.js index 986063b0..574bf230 100644 --- a/themes/example/components/SideBar.js +++ b/themes/example/components/SideBar.js @@ -7,7 +7,7 @@ const ExampleRecentComments = dynamic(() => import('./ExampleRecentComments')) export const SideBar = (props) => { const { locale } = useGlobal() - const { latestPosts, categories } = props + const { latestPosts, categoryOptions } = props return (
@@ -16,16 +16,16 @@ export const SideBar = (props) => {
@@ -40,9 +40,9 @@ export const SideBar = (props) => { {latestPosts?.map(p => { return ( -
  • {p.title}
  • +
  • {p.title}
  • - ); + ) })}
    @@ -61,5 +61,5 @@ export const SideBar = (props) => { - ); + ) } diff --git a/themes/fukasawa/LayoutCategoryIndex.js b/themes/fukasawa/LayoutCategoryIndex.js index e44e86dc..9e9cdd9c 100644 --- a/themes/fukasawa/LayoutCategoryIndex.js +++ b/themes/fukasawa/LayoutCategoryIndex.js @@ -4,7 +4,7 @@ import LayoutBase from './LayoutBase' export const LayoutCategoryIndex = (props) => { const { locale } = useGlobal() - const { categories } = props + const { categoryOptions } = props return (
    @@ -12,7 +12,7 @@ export const LayoutCategoryIndex = (props) => { {locale.COMMON.CATEGORY}:
    - {categories && categories.map(category => { + {categoryOptions?.map(category => { return ( { const { locale } = useGlobal() - const { tags } = props + const { tagOptions } = props return
    {locale.COMMON.TAGS}:
    - { tags.map(tag => { + { tagOptions.map(tag => { return
    }) }
    diff --git a/themes/fukasawa/components/AsideLeft.js b/themes/fukasawa/components/AsideLeft.js index 9b438bd4..adec77fa 100644 --- a/themes/fukasawa/components/AsideLeft.js +++ b/themes/fukasawa/components/AsideLeft.js @@ -9,9 +9,9 @@ import { useRouter } from 'next/router' import DarkModeButton from '@/components/DarkModeButton' function AsideLeft (props) { - const { tags, currentTag, categories, currentCategory, post, slot, siteInfo } = props + const { tagOptions, currentTag, categoryOptions, currentCategory, post, slot, siteInfo } = props const router = useRouter() - return
    + return
    @@ -31,12 +31,12 @@ function AsideLeft (props) { {router.asPath !== '/tag' &&

    - +
    } {router.asPath !== '/category' &&

    - +
    }
    diff --git a/themes/fukasawa/components/BlogCard.js b/themes/fukasawa/components/BlogCard.js index 1c42923f..328176ce 100644 --- a/themes/fukasawa/components/BlogCard.js +++ b/themes/fukasawa/components/BlogCard.js @@ -4,8 +4,14 @@ import React from 'react' import CONFIG_FUKA from '../config_fuka' import Card from './Card' -const BlogCard = ({ post, showSummary }) => { +const BlogCard = ({ post, showSummary, siteInfo }) => { const showPreview = CONFIG_FUKA.POST_LIST_PREVIEW && post.blockMap + // matery 主题默认强制显示图片 + if (post && !post.page_cover) { + post.page_cover = siteInfo?.pageCover + } + const showPageCover = CONFIG_FUKA.POST_LIST_COVER && post?.page_cover + return (
    { )}
    - {CONFIG_FUKA.POST_LIST_COVER && post?.page_cover && ( + {showPageCover && (
    {/* eslint-disable-next-line @next/next/no-img-element */} {post.title} {/* {post.title} */}
    @@ -45,7 +51,7 @@ const BlogCard = ({ post, showSummary }) => { )}
    - ); + ) } export default BlogCard diff --git a/themes/fukasawa/components/BlogListPage.js b/themes/fukasawa/components/BlogListPage.js index 98dfedff..2f0af0df 100644 --- a/themes/fukasawa/components/BlogListPage.js +++ b/themes/fukasawa/components/BlogListPage.js @@ -12,7 +12,7 @@ import PaginationSimple from './PaginationSimple' * @returns {JSX.Element} * @constructor */ -const BlogListPage = ({ page = 1, posts = [], postCount }) => { +const BlogListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { const totalPage = Math.ceil(postCount / BLOG.POSTS_PER_PAGE) const showNext = page < totalPage const [colCount, changeCol] = useState(1) @@ -44,7 +44,7 @@ const BlogListPage = ({ page = 1, posts = [], postCount }) => {
    {posts?.map(post => (
    - +
    ))}
    diff --git a/themes/fukasawa/components/BlogListScroll.js b/themes/fukasawa/components/BlogListScroll.js index 522d3f0e..003f789d 100644 --- a/themes/fukasawa/components/BlogListScroll.js +++ b/themes/fukasawa/components/BlogListScroll.js @@ -13,7 +13,7 @@ import throttle from 'lodash.throttle' * @constructor */ const BlogListScroll = props => { - const { posts = [] } = props + const { posts = [], siteInfo } = props const [colCount, changeCol] = React.useState(1) const { locale } = useGlobal() @@ -73,15 +73,13 @@ const BlogListScroll = props => {
    {postsToShow?.map(post => (
    - +
    ))}
    -
    +
    {' '} {hasMore ? locale.COMMON.MORE : `${locale.COMMON.NO_MORE} 😰`}{' '}
    diff --git a/themes/hexo/LayoutCategoryIndex.js b/themes/hexo/LayoutCategoryIndex.js index 7d7165a6..fc03ded2 100644 --- a/themes/hexo/LayoutCategoryIndex.js +++ b/themes/hexo/LayoutCategoryIndex.js @@ -4,7 +4,7 @@ import Card from './components/Card' import LayoutBase from './LayoutBase' export const LayoutCategoryIndex = props => { - const { categories } = props + const { categoryOptions } = props const { locale } = useGlobal() return ( @@ -14,7 +14,7 @@ export const LayoutCategoryIndex = props => { {locale.COMMON.CATEGORY}:
    - {categories.map(category => { + {categoryOptions.map(category => { return ( { - const tag = props.tags.find((t) => { + const tag = props.tagOptions.find((t) => { return t.name === props.tag }) diff --git a/themes/hexo/LayoutTagIndex.js b/themes/hexo/LayoutTagIndex.js index 7649a704..b754e1e3 100644 --- a/themes/hexo/LayoutTagIndex.js +++ b/themes/hexo/LayoutTagIndex.js @@ -4,7 +4,7 @@ import TagItemMini from './components/TagItemMini' import LayoutBase from './LayoutBase' export const LayoutTagIndex = props => { - const { tags } = props + const { tagOptions } = props const { locale } = useGlobal() return ( @@ -14,7 +14,7 @@ export const LayoutTagIndex = props => { {locale.COMMON.TAGS}:
    - {tags.map(tag => { + {tagOptions.map(tag => { return (
    diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index d0e9d1ee..819363fa 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -7,7 +7,7 @@ import NotionPage from '@/components/NotionPage' const BlogPostCard = ({ post, showSummary, index }) => { const showPreview = CONFIG_HEXO.POST_LIST_PREVIEW && post.blockMap - const showPageCover = CONFIG_HEXO.POST_LIST_COVER + const showPageCover = CONFIG_HEXO.POST_LIST_COVER && post?.page_cover return (
    { - const { postCount, categories, tags } = props + const { postCount, categoryOptions, tagOptions } = props const { locale } = useGlobal() const archiveSlot =
    {postCount}
    - const categorySlot =
    {categories?.length}
    - const tagSlot =
    {tags?.length}
    + const categorySlot =
    {categoryOptions?.length}
    + const tagSlot =
    {tagOptions?.length}
    const links = [ { name: locale.COMMON.ARTICLE, to: '/archive', slot: archiveSlot, show: CONFIG_HEXO.MENU_ARCHIVE }, @@ -34,12 +34,12 @@ const MenuGroupCard = (props) => {
    - ); + ) } else { return null } })} - ); + ) } export default MenuGroupCard diff --git a/themes/matery/LayoutCategory.js b/themes/matery/LayoutCategory.js index ab8a2b39..6e9524ab 100644 --- a/themes/matery/LayoutCategory.js +++ b/themes/matery/LayoutCategory.js @@ -6,7 +6,7 @@ import Link from 'next/link' import HeaderArticle from './components/HeaderArticle' export const LayoutCategory = props => { - const { category, categories } = props + const { category, categoryOptions } = props return ( } > @@ -15,7 +15,7 @@ export const LayoutCategory = props => {
    - {categories.map(e => { + {categoryOptions.map(e => { const selected = e.name === category return ( diff --git a/themes/matery/LayoutCategoryIndex.js b/themes/matery/LayoutCategoryIndex.js index fffc6ea5..31014270 100644 --- a/themes/matery/LayoutCategoryIndex.js +++ b/themes/matery/LayoutCategoryIndex.js @@ -3,7 +3,7 @@ import HeaderArticle from './components/HeaderArticle' import LayoutBase from './LayoutBase' export const LayoutCategoryIndex = props => { - const { categories } = props + const { categoryOptions } = props return ( } > @@ -13,7 +13,7 @@ export const LayoutCategoryIndex = props => {
    - {categories.map(e => { + {categoryOptions.map(e => { return (
    diff --git a/themes/matery/LayoutTag.js b/themes/matery/LayoutTag.js index 3f3d4fbd..3572d019 100644 --- a/themes/matery/LayoutTag.js +++ b/themes/matery/LayoutTag.js @@ -8,7 +8,7 @@ import { useGlobal } from '@/lib/global' import TagItemMiddle from './components/TagItemMiddle' export const LayoutTag = (props) => { - const { tags, tag } = props + const { tagOptions, tag } = props const { locale } = useGlobal() @@ -23,7 +23,7 @@ export const LayoutTag = (props) => {
    - {tags.map(e => { + {tagOptions.map(e => { const selected = tag === e.name return (
    diff --git a/themes/matery/LayoutTagIndex.js b/themes/matery/LayoutTagIndex.js index 7c196f7e..bfcb41b1 100644 --- a/themes/matery/LayoutTagIndex.js +++ b/themes/matery/LayoutTagIndex.js @@ -4,7 +4,7 @@ import TagItemMiddle from './components/TagItemMiddle' import LayoutBase from './LayoutBase' export const LayoutTagIndex = props => { - const { tags } = props + const { tagOptions } = props const { locale } = useGlobal() return ( } > @@ -17,7 +17,7 @@ export const LayoutTagIndex = props => {
    - {tags.map(tag => { + {tagOptions.map(tag => { return (
    diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js index 447b40d6..6a3d07b8 100644 --- a/themes/matery/components/BlogPostCard.js +++ b/themes/matery/components/BlogPostCard.js @@ -4,8 +4,13 @@ import React from 'react' import TagItemMini from './TagItemMini' import CONFIG_MATERY from '../config_matery' -const BlogPostCard = ({ post, showSummary }) => { +const BlogPostCard = ({ post, showSummary, siteInfo }) => { const showPreview = CONFIG_MATERY.POST_LIST_PREVIEW && post.blockMap + // matery 主题默认强制显示图片 + if (post && !post.page_cover) { + post.page_cover = siteInfo.pageCover + } + const showPageCover = CONFIG_MATERY.POST_LIST_COVER && !showPreview && post?.page_cover return (
    {
    {/* 头部图片 填充卡片 */} - {CONFIG_MATERY.POST_LIST_COVER && !showPreview && post?.page_cover && ( + {showPageCover && (
    {/* eslint-disable-next-line @next/next/no-img-element */} diff --git a/themes/matery/components/BlogPostListPage.js b/themes/matery/components/BlogPostListPage.js index 0a4eec12..2a458aea 100644 --- a/themes/matery/components/BlogPostListPage.js +++ b/themes/matery/components/BlogPostListPage.js @@ -11,7 +11,7 @@ import PaginationSimple from './PaginationSimple' * @returns {JSX.Element} * @constructor */ -const BlogPostListPage = ({ page = 1, posts = [], postCount }) => { +const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { const totalPage = Math.ceil(postCount / BLOG.POSTS_PER_PAGE) const showPagination = postCount >= BLOG.POSTS_PER_PAGE if (!posts || posts.length === 0 || page > totalPage) { @@ -23,7 +23,7 @@ const BlogPostListPage = ({ page = 1, posts = [], postCount }) => { {/* 文章列表 */}
    {posts.map(post => ( - + ))}
    {showPagination && } diff --git a/themes/matery/components/BlogPostListScroll.js b/themes/matery/components/BlogPostListScroll.js index 9c243ade..105d32db 100644 --- a/themes/matery/components/BlogPostListScroll.js +++ b/themes/matery/components/BlogPostListScroll.js @@ -14,7 +14,7 @@ import { getListByPage } from '@/lib/utils' * @returns {JSX.Element} * @constructor */ -const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG_MATERY.POST_LIST_SUMMARY }) => { +const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG_MATERY.POST_LIST_SUMMARY, siteInfo }) => { const postsPerPage = BLOG.POSTS_PER_PAGE const [page, updatePage] = React.useState(1) const postsToShow = getListByPage(posts, page, postsPerPage) @@ -58,7 +58,7 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG_MA {/* 文章列表 */}
    {postsToShow.map(post => ( - + ))}
    diff --git a/themes/medium/LayoutCategoryIndex.js b/themes/medium/LayoutCategoryIndex.js index 5d200fe2..c9c79254 100644 --- a/themes/medium/LayoutCategoryIndex.js +++ b/themes/medium/LayoutCategoryIndex.js @@ -3,7 +3,7 @@ import Link from 'next/link' import LayoutBase from './LayoutBase' export const LayoutCategoryIndex = (props) => { - const { categories } = props + const { categoryOptions } = props const { locale } = useGlobal() return ( @@ -12,7 +12,7 @@ export const LayoutCategoryIndex = (props) => { {locale.COMMON.CATEGORY}:
    - {categories && categories.map(category => { + {categoryOptions?.map(category => { return ( { - const { tags } = props + const { tagOptions } = props const { locale } = useGlobal() return ( @@ -13,7 +13,7 @@ export const LayoutTagIndex = props => { {locale.COMMON.TAGS}:
    - {tags.map(tag => { + {tagOptions.map(tag => { return (
    diff --git a/themes/next/LayoutCategory.js b/themes/next/LayoutCategory.js index 063918d4..ec71cb95 100644 --- a/themes/next/LayoutCategory.js +++ b/themes/next/LayoutCategory.js @@ -6,10 +6,10 @@ import BlogPostListPage from './components/BlogPostListPage' import BLOG from '@/blog.config' export const LayoutCategory = (props) => { - const { category, categories } = props + const { category, categoryOptions } = props return - +
    {BLOG.POST_LIST_STYLE !== 'page' diff --git a/themes/next/LayoutCategoryIndex.js b/themes/next/LayoutCategoryIndex.js index 9089fff8..0dd99e0f 100644 --- a/themes/next/LayoutCategoryIndex.js +++ b/themes/next/LayoutCategoryIndex.js @@ -3,7 +3,7 @@ import LayoutBase from './LayoutBase' import Link from 'next/link' export const LayoutCategoryIndex = (props) => { - const { allPosts, categories } = props + const { allPosts, categoryOptions } = props const { locale } = useGlobal() return ( @@ -12,7 +12,7 @@ export const LayoutCategoryIndex = (props) => { {locale.COMMON.CATEGORY}:
    - {categories.map(category => { + {categoryOptions.map(category => { return ( { {category.name}({category.count})
    - ); + ) })}
    - ); + ) } diff --git a/themes/next/LayoutTag.js b/themes/next/LayoutTag.js index fdb47239..c70307e8 100644 --- a/themes/next/LayoutTag.js +++ b/themes/next/LayoutTag.js @@ -6,11 +6,11 @@ import BlogPostListPage from './components/BlogPostListPage' import BLOG from '@/blog.config' export const LayoutTag = (props) => { - const { tags, tag } = props + const { tagOptions, tag } = props return - +
    {BLOG.POST_LIST_STYLE !== 'page' diff --git a/themes/next/LayoutTagIndex.js b/themes/next/LayoutTagIndex.js index 45100a9e..5278dd8f 100644 --- a/themes/next/LayoutTagIndex.js +++ b/themes/next/LayoutTagIndex.js @@ -3,13 +3,13 @@ import LayoutBase from './LayoutBase' import TagItem from './components/TagItem' export const LayoutTagIndex = (props) => { - const { tags } = props + const { tagOptions } = props const { locale } = useGlobal() return
    {locale.COMMON.TAGS}:
    - { tags.map(tag => { + { tagOptions.map(tag => { return
    }) }
    diff --git a/themes/next/components/CategoryList.js b/themes/next/components/CategoryList.js index 2d384479..ffe038ef 100644 --- a/themes/next/components/CategoryList.js +++ b/themes/next/components/CategoryList.js @@ -2,16 +2,16 @@ import Link from 'next/link' import React from 'react' import { useGlobal } from '@/lib/global' -const CategoryList = ({ currentCategory, categories }) => { - if (!categories) { +const CategoryList = ({ currentCategory, categoryOptions }) => { + const { locale } = useGlobal() + if (!categoryOptions) { return <> } - const { locale } = useGlobal() return (
    • {locale.COMMON.CATEGORY}
    • - {categories.map(category => { + {categoryOptions.map(category => { const selected = category.name === currentCategory return ( { - ); + ) })}
    - ); + ) } export default CategoryList diff --git a/themes/next/components/TagList.js b/themes/next/components/TagList.js index f5b7d030..973e7b68 100644 --- a/themes/next/components/TagList.js +++ b/themes/next/components/TagList.js @@ -7,13 +7,13 @@ import TagItem from './TagItem' * @returns {JSX.Element} * @constructor */ -const TagList = ({ tags, currentTag }) => { - if (!tags) { +const TagList = ({ tagOptions, currentTag }) => { + if (!tagOptions) { return <> } return
    • 标签:
    • - {tags.map(tag => { + {tagOptions.map(tag => { const selected = tag.name === currentTag return })} diff --git a/themes/nobelium/LayoutBase.js b/themes/nobelium/LayoutBase.js index 7e6ec817..598a9b9b 100644 --- a/themes/nobelium/LayoutBase.js +++ b/themes/nobelium/LayoutBase.js @@ -16,7 +16,7 @@ const LayoutBase = props => { const fullWidth = post?.fullWidth ?? false return ( -
      +
      {/* 顶部导航栏 */} diff --git a/themes/nobelium/LayoutCategoryIndex.js b/themes/nobelium/LayoutCategoryIndex.js index 6d1884ab..3cf9c10d 100644 --- a/themes/nobelium/LayoutCategoryIndex.js +++ b/themes/nobelium/LayoutCategoryIndex.js @@ -2,12 +2,12 @@ import Link from 'next/link' import LayoutBase from './LayoutBase' export const LayoutCategoryIndex = (props) => { - const { categories } = props + const { categoryOptions } = props return (
      - {categories && categories.map(category => { + {categoryOptions?.map(category => { return ( { {category.name}({category.count})
      - ); + ) })}
      - ); + ) } diff --git a/themes/nobelium/LayoutTagIndex.js b/themes/nobelium/LayoutTagIndex.js index 6d2873a8..0705c2d6 100644 --- a/themes/nobelium/LayoutTagIndex.js +++ b/themes/nobelium/LayoutTagIndex.js @@ -2,12 +2,12 @@ import Link from 'next/link' import LayoutBase from './LayoutBase' export const LayoutTagIndex = (props) => { - const { tags } = props + const { tagOptions } = props return (
      - {tags.map(tag => { + {tagOptions.map(tag => { return (
      {
      - ); + ) })}
      - ); + ) }