Merge branch 'theme-next' into main

This commit is contained in:
tangly1024
2022-02-28 14:38:38 +08:00
15 changed files with 49 additions and 43 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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 <LayoutBase meta={{ title: `${BLOG.TITLE} | 页面找不到啦` }}>
return <LayoutBase meta={{ title: `${BLOG.TITLE} | 页面找不到啦` }} {...props}>
<div
className='md:-mt-20 text-black w-full h-screen text-center justify-center content-center items-center flex flex-col'>
<div className='dark:text-gray-200'>

View File

@@ -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 (
<LayoutBase meta={meta} tags={tags} categories={categories} postCount={postCount}>
<LayoutBase meta={meta} {...props}>
<div className="mb-10 pb-20 bg-white md:p-12 p-3 dark:bg-gray-800 shadow-md min-h-full">
{Object.keys(archivePosts).map(archiveTitle => (
<BlogPostArchive

View File

@@ -5,14 +5,15 @@ import StickyBar from './components/StickyBar'
import CategoryList from './components/CategoryList'
import BlogPostListScroll from './components/BlogPostListScroll'
export const LayoutCategory = ({ tags, posts, category, categories, latestPosts, postCount }) => {
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 <LayoutBase meta={meta} tags={tags} currentCategory={category} postCount={postCount} latestPosts={latestPosts} categories={categories}>
return <LayoutBase meta={meta} currentCategory={category} {...props}>
<StickyBar>
<CategoryList currentCategory={category} categories={categories} />
</StickyBar>

View File

@@ -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 <LayoutBase meta={meta} totalPosts={allPosts} tags={tags} postCount={postCount} latestPosts={latestPosts}>
return <LayoutBase meta={meta} totalPosts={allPosts} {...props}>
<div className='bg-white dark:bg-gray-700 px-10 py-10 shadow'>
<div className='dark:text-gray-200 mb-5'>
<i className='mr-4 fas faTh' />{locale.COMMON.CATEGORY}:

View File

@@ -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 (
<LayoutBase
meta={meta}
tags={tags}
sideBarSlot={<LatestPostsGroup posts={latestPosts} />}
rightAreaSlot={CONFIG_NEXT.RIGHT_LATEST_POSTS && <LatestPostsGroup posts={latestPosts} />}
postCount={postCount}
categories={categories}
{...props}
>
<BlogPostListPage page={page} posts={posts} postCount={postCount} />
<BlogPostListPage {...props}/>
</LayoutBase>
)
}

View File

@@ -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 (
<LayoutBase
meta={meta}
tags={tags}
postCount={postCount}
currentSearch={searchKey}
categories={categories}
{...props}
>
<StickyBar>
<div className="p-4 dark:text-gray-200">

View File

@@ -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 <LayoutBase meta={meta} tags={tags} currentTag={tag} categories={categories} postCount={postCount} latestPosts={latestPosts}>
return <LayoutBase meta={meta} currentTag={tag} {...props}>
<StickyBar>
<TagList tags={newTags} currentTag={tag}/>
</StickyBar>

View File

@@ -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 <LayoutBase meta={meta} categories={categories} postCount={postCount} latestPosts={latestPosts}>
return <LayoutBase meta={meta} {...props}>
<div className='bg-white dark:bg-gray-700 px-10 py-10 shadow'>
<div className='dark:text-gray-200 mb-5'><i className='fas fa-tags mr-4'/>{locale.COMMON.TAGS}:</div>
<div id='tags-list' className='duration-200 flex flex-wrap'>