Merge branch 'main' into theme-medium

This commit is contained in:
tangly1024
2022-02-28 14:41:27 +08:00
18 changed files with 54 additions and 47 deletions

View File

@@ -3,7 +3,7 @@ import React from 'react'
import { LayoutArchive } from '@/themes' import { LayoutArchive } from '@/themes'
export async function getStaticProps () { export async function getStaticProps () {
const { allPosts, categories, tags, postCount } = const { allPosts, categories, tags, postCount, customNav } =
await getGlobalNotionData({ from: 'archive-index' }) await getGlobalNotionData({ from: 'archive-index' })
return { return {
@@ -11,7 +11,8 @@ export async function getStaticProps () {
posts: allPosts, posts: allPosts,
tags, tags,
categories, categories,
postCount postCount,
customNav
}, },
revalidate: 1 revalidate: 1
} }

View File

@@ -14,7 +14,8 @@ export async function getStaticProps ({ params }) {
categories, categories,
tags, tags,
postCount, postCount,
latestPosts latestPosts,
customNav
} = await getGlobalNotionData({ from }) } = await getGlobalNotionData({ from })
const filteredPosts = allPosts.filter( const filteredPosts = allPosts.filter(
post => post && post.category && post.category.includes(category) post => post && post.category && post.category.includes(category)
@@ -26,7 +27,8 @@ export async function getStaticProps ({ params }) {
category, category,
categories, categories,
postCount, postCount,
latestPosts latestPosts,
customNav
}, },
revalidate: 1 revalidate: 1
} }

View File

@@ -8,7 +8,7 @@ export default function Category (props) {
export async function getStaticProps () { export async function getStaticProps () {
const from = 'category-index-props' 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 { return {
props: { props: {
@@ -16,7 +16,8 @@ export async function getStaticProps () {
allPosts, allPosts,
categories, categories,
postCount, postCount,
latestPosts latestPosts,
customNav
}, },
revalidate: 1 revalidate: 1
} }

View File

@@ -29,7 +29,8 @@ export async function getStaticProps ({ params: { page } }) {
latestPosts, latestPosts,
categories, categories,
tags, tags,
postCount postCount,
customNav
} = await getGlobalNotionData({ from }) } = await getGlobalNotionData({ from })
const meta = { const meta = {
title: `${page} | Page | ${BLOG.TITLE}`, title: `${page} | Page | ${BLOG.TITLE}`,
@@ -62,7 +63,8 @@ export async function getStaticProps ({ params: { page } }) {
latestPosts, latestPosts,
tags, tags,
categories, categories,
meta meta,
customNav
}, },
revalidate: 1 revalidate: 1
} }

View File

@@ -7,7 +7,8 @@ export async function getStaticProps () {
categories, categories,
tags, tags,
postCount, postCount,
latestPosts latestPosts,
customNav
} = await getGlobalNotionData({ from: 'search-props', pageType: ['Post'] }) } = await getGlobalNotionData({ from: 'search-props', pageType: ['Post'] })
return { return {
props: { props: {
@@ -15,7 +16,8 @@ export async function getStaticProps () {
tags, tags,
categories, categories,
postCount, postCount,
latestPosts latestPosts,
customNav
}, },
revalidate: 1 revalidate: 1
} }

View File

@@ -13,7 +13,8 @@ export async function getStaticProps ({ params }) {
categories, categories,
tags, tags,
postCount, postCount,
latestPosts latestPosts,
customNav
} = await getGlobalNotionData({ } = await getGlobalNotionData({
from, from,
includePage: false, includePage: false,
@@ -29,7 +30,8 @@ export async function getStaticProps ({ params }) {
tag, tag,
categories, categories,
postCount, postCount,
latestPosts latestPosts,
customNav
}, },
revalidate: 1 revalidate: 1
} }

View File

@@ -8,14 +8,15 @@ const TagIndex = (props) => {
export async function getStaticProps () { export async function getStaticProps () {
const from = 'tag-index-props' 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 { return {
props: { props: {
tags, tags,
categories, categories,
postCount, postCount,
latestPosts latestPosts,
customNav
}, },
revalidate: 1 revalidate: 1
} }

View File

@@ -3,7 +3,7 @@ import LayoutBase from './LayoutBase'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import { useEffect } from 'react' import { useEffect } from 'react'
export const Layout404 = () => { export const Layout404 = (props) => {
const router = useRouter() const router = useRouter()
useEffect(() => { useEffect(() => {
// 延时3秒如果加载失败就返回首页 // 延时3秒如果加载失败就返回首页
@@ -19,7 +19,7 @@ export const Layout404 = () => {
}, 3000) }, 3000)
}) })
return <LayoutBase meta={{ title: `${BLOG.TITLE} | 页面找不到啦` }}> return <LayoutBase meta={{ title: `${BLOG.TITLE} | 页面找不到啦` }} {...props}>
<div <div
className='md:-mt-20 text-black w-full h-screen text-center justify-center content-center items-center flex flex-col'> 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'> <div className='dark:text-gray-200'>

View File

@@ -5,7 +5,8 @@ import LayoutBase from './LayoutBase'
import BlogPostArchive from './components/BlogPostArchive' import BlogPostArchive from './components/BlogPostArchive'
import Live2D from './components/Live2D' import Live2D from './components/Live2D'
export const LayoutArchive = ({ posts, tags, categories, postCount }) => { export const LayoutArchive = (props) => {
const { posts } = props
const { locale } = useGlobal() const { locale } = useGlobal()
// 深拷贝 // 深拷贝
const postsSortByDate = Object.create(posts) const postsSortByDate = Object.create(posts)
@@ -49,7 +50,7 @@ export const LayoutArchive = ({ posts, tags, categories, postCount }) => {
}, []) }, [])
return ( 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"> <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 => ( {Object.keys(archivePosts).map(archiveTitle => (
<BlogPostArchive <BlogPostArchive

View File

@@ -5,14 +5,15 @@ import StickyBar from './components/StickyBar'
import CategoryList from './components/CategoryList' import CategoryList from './components/CategoryList'
import BlogPostListScroll from './components/BlogPostListScroll' 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 { locale } = useGlobal()
const meta = { const meta = {
title: `${category} | ${locale.COMMON.CATEGORY} | ${BLOG.TITLE}`, title: `${category} | ${locale.COMMON.CATEGORY} | ${BLOG.TITLE}`,
description: BLOG.DESCRIPTION, description: BLOG.DESCRIPTION,
type: 'website' type: 'website'
} }
return <LayoutBase meta={meta} tags={tags} currentCategory={category} postCount={postCount} latestPosts={latestPosts} categories={categories}> return <LayoutBase meta={meta} currentCategory={category} {...props}>
<StickyBar> <StickyBar>
<CategoryList currentCategory={category} categories={categories} /> <CategoryList currentCategory={category} categories={categories} />
</StickyBar> </StickyBar>

View File

@@ -3,20 +3,15 @@ import BLOG from '@/blog.config'
import LayoutBase from './LayoutBase' import LayoutBase from './LayoutBase'
import Link from 'next/link' import Link from 'next/link'
export const LayoutCategoryIndex = ({ export const LayoutCategoryIndex = (props) => {
tags, const { allPosts, categories } = props
allPosts,
categories,
postCount,
latestPosts
}) => {
const { locale } = useGlobal() const { locale } = useGlobal()
const meta = { const meta = {
title: `${locale.COMMON.CATEGORY} | ${BLOG.TITLE}`, title: `${locale.COMMON.CATEGORY} | ${BLOG.TITLE}`,
description: BLOG.DESCRIPTION, description: BLOG.DESCRIPTION,
type: 'website' 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='bg-white dark:bg-gray-700 px-10 py-10 shadow'>
<div className='dark:text-gray-200 mb-5'> <div className='dark:text-gray-200 mb-5'>
<i className='mr-4 fas faTh' />{locale.COMMON.CATEGORY}: <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 BlogPostListPage from './components/BlogPostListPage'
import CONFIG_NEXT from './config_next' import CONFIG_NEXT from './config_next'
export const LayoutPage = ({ page, posts, tags, meta, categories, postCount, latestPosts }) => { export const LayoutPage = (props) => {
const { latestPosts } = props
return ( return (
<LayoutBase <LayoutBase
meta={meta}
tags={tags}
sideBarSlot={<LatestPostsGroup posts={latestPosts} />} sideBarSlot={<LatestPostsGroup posts={latestPosts} />}
rightAreaSlot={CONFIG_NEXT.RIGHT_LATEST_POSTS && <LatestPostsGroup posts={latestPosts} />} rightAreaSlot={CONFIG_NEXT.RIGHT_LATEST_POSTS && <LatestPostsGroup posts={latestPosts} />}
postCount={postCount} {...props}
categories={categories}
> >
<BlogPostListPage page={page} posts={posts} postCount={postCount} /> <BlogPostListPage {...props}/>
</LayoutBase> </LayoutBase>
) )
} }

View File

@@ -5,7 +5,8 @@ import { useGlobal } from '@/lib/global'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
export const LayoutSearch = ({ posts, tags, categories, postCount }) => { export const LayoutSearch = (props) => {
const { posts, tags } = props
let filteredPosts let filteredPosts
const searchKey = getSearchKey() const searchKey = getSearchKey()
if (searchKey) { if (searchKey) {
@@ -27,10 +28,8 @@ export const LayoutSearch = ({ posts, tags, categories, postCount }) => {
return ( return (
<LayoutBase <LayoutBase
meta={meta} meta={meta}
tags={tags}
postCount={postCount}
currentSearch={searchKey} currentSearch={searchKey}
categories={categories} {...props}
> >
<StickyBar> <StickyBar>
<div className="p-4 dark:text-gray-200"> <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 TagList from './components/TagList'
import BlogPostListScroll from './components/BlogPostListScroll' 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 { locale } = useGlobal()
const meta = { 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 currentTag = tags?.find(r => r?.name === tag)
const newTags = currentTag ? [currentTag].concat(tags.filter(r => r?.name !== tag)) : tags.filter(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> <StickyBar>
<TagList tags={newTags} currentTag={tag}/> <TagList tags={newTags} currentTag={tag}/>
</StickyBar> </StickyBar>

View File

@@ -3,14 +3,15 @@ import BLOG from '@/blog.config'
import LayoutBase from './LayoutBase' import LayoutBase from './LayoutBase'
import TagItem from './components/TagItem' import TagItem from './components/TagItem'
export const LayoutTagIndex = ({ tags, categories, postCount, latestPosts }) => { export const LayoutTagIndex = (props) => {
const { tags } = props
const { locale } = useGlobal() const { locale } = useGlobal()
const meta = { const meta = {
title: `${locale.COMMON.TAGS} | ${BLOG.TITLE}`, title: `${locale.COMMON.TAGS} | ${BLOG.TITLE}`,
description: BLOG.DESCRIPTION, description: BLOG.DESCRIPTION,
type: 'website' 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='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 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'> <div id='tags-list' className='duration-200 flex flex-wrap'>

View File

@@ -7,7 +7,7 @@ import SocialButton from './SocialButton'
const InfoCard = () => { const InfoCard = () => {
return <> return <>
<div className='flex flex-col items-center justify-center '> <div className='flex flex-col items-center justify-center '>
<div className='hover:rotate-45 hover:scale-125 transform duration-200 cursor-pointer' onClick={ () => { Router.push('/about') }}> <div className='hover:rotate-45 hover:scale-125 transform duration-200 cursor-pointer' onClick={ () => { Router.push('/') }}>
<Image <Image
alt={BLOG.AUTHOR} alt={BLOG.AUTHOR}
width={120} width={120}

View File

@@ -19,10 +19,11 @@ const CONFIG_NEXT = {
RIGHT_AD: false, // 右侧广告 RIGHT_AD: false, // 右侧广告
// 菜单 // 菜单
MENU_ABOUT: false, // 显示关于 MENU_HOME: true, // 显示首页
MENU_CATEGORY: true, // 显示分类 MENU_CATEGORY: true, // 显示分类
MENU_TAG: true, // 显示标签 MENU_TAG: true, // 显示标签
MENU_ARCHIVE: true, // 显示归档 MENU_ARCHIVE: true, // 显示归档
MENU_ABOUT: false, // 显示关于
MENU_SEARCH: true, // 显示搜索 MENU_SEARCH: true, // 显示搜索
// 悬浮挂件 // 悬浮挂件

View File

@@ -3,7 +3,7 @@
*/ */
// export * from './Empty' // 空主题 // export * from './Empty' // 空主题
// export * from './NEXT' export * from './NEXT'
// export * from './Fukasawa' // export * from './Fukasawa'
// export * from './Hexo' // export * from './Hexo'
export * from './Medium' // export * from './Medium'