diff --git a/pages/archive/index.js b/pages/archive/index.js index 3e4a4f52..4dffb49d 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -3,7 +3,7 @@ import React from 'react' import { LayoutArchive } from '@/themes' export async function getStaticProps () { - const { allPosts, categories, tags, postCount } = + const { allPosts, categories, tags, postCount, customNav } = await getGlobalNotionData({ from: 'archive-index' }) return { @@ -11,7 +11,8 @@ export async function getStaticProps () { posts: allPosts, tags, categories, - postCount + postCount, + customNav }, revalidate: 1 } diff --git a/pages/category/[category].js b/pages/category/[category].js index a2ecff19..681a23c6 100644 --- a/pages/category/[category].js +++ b/pages/category/[category].js @@ -14,7 +14,8 @@ export async function getStaticProps ({ params }) { categories, tags, postCount, - latestPosts + latestPosts, + customNav } = await getGlobalNotionData({ from }) const filteredPosts = allPosts.filter( post => post && post.category && post.category.includes(category) @@ -26,7 +27,8 @@ export async function getStaticProps ({ params }) { category, categories, postCount, - latestPosts + latestPosts, + customNav }, revalidate: 1 } diff --git a/pages/category/index.js b/pages/category/index.js index c295f452..f9739597 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -8,7 +8,7 @@ export default function Category (props) { export async function getStaticProps () { const from = 'category-index-props' - const { allPosts, categories, tags, postCount, latestPosts } = await getGlobalNotionData({ from }) + const { allPosts, categories, tags, postCount, latestPosts, customNav } = await getGlobalNotionData({ from }) return { props: { @@ -16,7 +16,8 @@ export async function getStaticProps () { allPosts, categories, postCount, - latestPosts + latestPosts, + customNav }, revalidate: 1 } diff --git a/pages/page/[page].js b/pages/page/[page].js index d39e49a2..f0f67312 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -29,7 +29,8 @@ export async function getStaticProps ({ params: { page } }) { latestPosts, categories, tags, - postCount + postCount, + customNav } = await getGlobalNotionData({ from }) const meta = { title: `${page} | Page | ${BLOG.TITLE}`, @@ -62,7 +63,8 @@ export async function getStaticProps ({ params: { page } }) { latestPosts, tags, categories, - meta + meta, + customNav }, revalidate: 1 } diff --git a/pages/search.js b/pages/search.js index 5f765482..57bc57fb 100644 --- a/pages/search.js +++ b/pages/search.js @@ -7,7 +7,8 @@ export async function getStaticProps () { categories, tags, postCount, - latestPosts + latestPosts, + customNav } = await getGlobalNotionData({ from: 'search-props', pageType: ['Post'] }) return { props: { @@ -15,7 +16,8 @@ export async function getStaticProps () { tags, categories, postCount, - latestPosts + latestPosts, + customNav }, revalidate: 1 } diff --git a/pages/tag/[tag].js b/pages/tag/[tag].js index 01cf5220..169352f6 100644 --- a/pages/tag/[tag].js +++ b/pages/tag/[tag].js @@ -13,7 +13,8 @@ export async function getStaticProps ({ params }) { categories, tags, postCount, - latestPosts + latestPosts, + customNav } = await getGlobalNotionData({ from, includePage: false, @@ -29,7 +30,8 @@ export async function getStaticProps ({ params }) { tag, categories, postCount, - latestPosts + latestPosts, + customNav }, revalidate: 1 } diff --git a/pages/tag/index.js b/pages/tag/index.js index eda44e7d..cdf8a401 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -8,14 +8,15 @@ const TagIndex = (props) => { export async function getStaticProps () { const from = 'tag-index-props' - const { categories, tags, postCount, latestPosts } = await getGlobalNotionData({ from, tagsCount: 0 }) + const { categories, tags, postCount, latestPosts, customNav } = await getGlobalNotionData({ from, tagsCount: 0 }) return { props: { tags, categories, postCount, - latestPosts + latestPosts, + customNav }, revalidate: 1 } diff --git a/themes/NEXT/Layout404.js b/themes/NEXT/Layout404.js index ff7a14a7..9c51b293 100644 --- a/themes/NEXT/Layout404.js +++ b/themes/NEXT/Layout404.js @@ -3,7 +3,7 @@ import LayoutBase from './LayoutBase' import BLOG from '@/blog.config' import { useEffect } from 'react' -export const Layout404 = () => { +export const Layout404 = (props) => { const router = useRouter() useEffect(() => { // 延时3秒如果加载失败就返回首页 @@ -19,7 +19,7 @@ export const Layout404 = () => { }, 3000) }) - return + return
diff --git a/themes/NEXT/LayoutArchive.js b/themes/NEXT/LayoutArchive.js index dfe77318..0b2d99e5 100644 --- a/themes/NEXT/LayoutArchive.js +++ b/themes/NEXT/LayoutArchive.js @@ -5,7 +5,8 @@ import LayoutBase from './LayoutBase' import BlogPostArchive from './components/BlogPostArchive' import Live2D from './components/Live2D' -export const LayoutArchive = ({ posts, tags, categories, postCount }) => { +export const LayoutArchive = (props) => { + const { posts } = props const { locale } = useGlobal() // 深拷贝 const postsSortByDate = Object.create(posts) @@ -49,7 +50,7 @@ export const LayoutArchive = ({ posts, tags, categories, postCount }) => { }, []) return ( - +
{Object.keys(archivePosts).map(archiveTitle => ( { +export const LayoutCategory = (props) => { + const { tags, posts, category, categories } = props const { locale } = useGlobal() const meta = { title: `${category} | ${locale.COMMON.CATEGORY} | ${BLOG.TITLE}`, description: BLOG.DESCRIPTION, type: 'website' } - return + return diff --git a/themes/NEXT/LayoutCategoryIndex.js b/themes/NEXT/LayoutCategoryIndex.js index a6cf3eea..b4a5ef51 100644 --- a/themes/NEXT/LayoutCategoryIndex.js +++ b/themes/NEXT/LayoutCategoryIndex.js @@ -3,20 +3,15 @@ import BLOG from '@/blog.config' import LayoutBase from './LayoutBase' import Link from 'next/link' -export const LayoutCategoryIndex = ({ - tags, - allPosts, - categories, - postCount, - latestPosts -}) => { +export const LayoutCategoryIndex = (props) => { + const { allPosts, categories } = props const { locale } = useGlobal() const meta = { title: `${locale.COMMON.CATEGORY} | ${BLOG.TITLE}`, description: BLOG.DESCRIPTION, type: 'website' } - return + return
{locale.COMMON.CATEGORY}: diff --git a/themes/NEXT/LayoutPage.js b/themes/NEXT/LayoutPage.js index 5680c9b9..7cd06dab 100644 --- a/themes/NEXT/LayoutPage.js +++ b/themes/NEXT/LayoutPage.js @@ -3,17 +3,15 @@ import LatestPostsGroup from './components/LatestPostsGroup' import BlogPostListPage from './components/BlogPostListPage' import CONFIG_NEXT from './config_next' -export const LayoutPage = ({ page, posts, tags, meta, categories, postCount, latestPosts }) => { +export const LayoutPage = (props) => { + const { latestPosts } = props return ( } rightAreaSlot={CONFIG_NEXT.RIGHT_LATEST_POSTS && } - postCount={postCount} - categories={categories} + {...props} > - + ) } diff --git a/themes/NEXT/LayoutSearch.js b/themes/NEXT/LayoutSearch.js index 35aacdce..21f34de0 100644 --- a/themes/NEXT/LayoutSearch.js +++ b/themes/NEXT/LayoutSearch.js @@ -5,7 +5,8 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' -export const LayoutSearch = ({ posts, tags, categories, postCount }) => { +export const LayoutSearch = (props) => { + const { posts, tags } = props let filteredPosts const searchKey = getSearchKey() if (searchKey) { @@ -27,10 +28,8 @@ export const LayoutSearch = ({ posts, tags, categories, postCount }) => { return (
diff --git a/themes/NEXT/LayoutTag.js b/themes/NEXT/LayoutTag.js index bebc4cb2..47d0580b 100644 --- a/themes/NEXT/LayoutTag.js +++ b/themes/NEXT/LayoutTag.js @@ -5,7 +5,8 @@ import StickyBar from './components/StickyBar' import TagList from './components/TagList' import BlogPostListScroll from './components/BlogPostListScroll' -export const LayoutTag = ({ tags, posts, tag, categories, postCount, latestPosts }) => { +export const LayoutTag = (props) => { + const { tags, posts, tag } = props const { locale } = useGlobal() const meta = { @@ -15,11 +16,10 @@ export const LayoutTag = ({ tags, posts, tag, categories, postCount, latestPosts } // 将当前选中的标签置顶🔝 - if (!tags) tags = [] const currentTag = tags?.find(r => r?.name === tag) const newTags = currentTag ? [currentTag].concat(tags.filter(r => r?.name !== tag)) : tags.filter(r => r?.name !== tag) - return + return diff --git a/themes/NEXT/LayoutTagIndex.js b/themes/NEXT/LayoutTagIndex.js index 801461a9..8ddd5bc4 100644 --- a/themes/NEXT/LayoutTagIndex.js +++ b/themes/NEXT/LayoutTagIndex.js @@ -3,14 +3,15 @@ import BLOG from '@/blog.config' import LayoutBase from './LayoutBase' import TagItem from './components/TagItem' -export const LayoutTagIndex = ({ tags, categories, postCount, latestPosts }) => { +export const LayoutTagIndex = (props) => { + const { tags } = props const { locale } = useGlobal() const meta = { title: `${locale.COMMON.TAGS} | ${BLOG.TITLE}`, description: BLOG.DESCRIPTION, type: 'website' } - return + return
{locale.COMMON.TAGS}: