feature: 切换主题

This commit is contained in:
tangly1024
2022-01-15 21:38:47 +08:00
parent a6903b1d52
commit 018af8fe7f
24 changed files with 101 additions and 109 deletions

View File

@@ -1,4 +1,4 @@
import { Custom404Layout } from '@/themes'
import { Layout404 } from '@/themes'
/**
* 自定义404界面
@@ -7,5 +7,5 @@ import { Custom404Layout } from '@/themes'
*/
export default function Custom404 () {
return <Custom404Layout />
return <Layout404 />
}

View File

@@ -2,18 +2,18 @@ import { getPostBlocks } from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import Custom404 from '@/pages/404'
import React from 'react'
import { ArticleLayout } from '@/themes'
import { LayoutSlug } from '@/themes'
/**
* 关于页面默认取notion中slug为about的文章
* @param {*} param0
* @param {*} props
* @returns
*/
const About = (props) => {
if (!props.post) {
return <Custom404 />
}
return <ArticleLayout {...props} />
return <LayoutSlug {...props} />
}
export async function getStaticProps () {

View File

@@ -1,6 +1,6 @@
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import React from 'react'
import { ArchiveLayout } from '@/themes'
import { LayoutArchive } from '@/themes'
export async function getStaticProps () {
const { allPosts, categories, tags, postCount } =
@@ -18,7 +18,7 @@ export async function getStaticProps () {
}
const ArchiveIndex = (props) => {
return <ArchiveLayout {...props}/>
return <LayoutArchive {...props}/>
}
export default ArchiveIndex

View File

@@ -1,19 +1,19 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import { ArticleLayout } from '@/themes'
import { LayoutSlug } from '@/themes'
import Custom404 from '@/pages/404'
/**
* 根据notion的slug访问页面
* @param {*} param0
* @param {*} props
* @returns
*/
const Slug = (props) => {
if (!props.post) {
return <Custom404 />
}
return <ArticleLayout {...props}/>
return <LayoutSlug {...props}/>
}
export async function getStaticPaths () {
@@ -69,7 +69,7 @@ export async function getStaticProps ({ params: { slug } }) {
/**
*
* @param {获取文章推荐文章} post
* @param post
* @param {*} allPosts
* @param {*} count
* @returns

View File

@@ -1,9 +1,9 @@
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import React from 'react'
import { CategoryLayout } from '@/themes'
import { LayoutCategory } from '@/themes'
export default function Category (props) {
return <CategoryLayout {...props} />
return <LayoutCategory {...props} />
}
export async function getStaticProps ({ params }) {

View File

@@ -1,9 +1,9 @@
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import React from 'react'
import { CategoryIndexLayout } from '@/themes'
import { LayoutCategoryIndex } from '@/themes'
export default function Category (props) {
return <CategoryIndexLayout {...props}/>
return <LayoutCategoryIndex {...props}/>
}
export async function getStaticProps () {

View File

@@ -1,10 +1,10 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import { IndexLayout } from '@/themes'
import { LayoutIndex } from '@/themes'
const Index = (props) => {
return <IndexLayout {...props}/>
return <LayoutIndex {...props}/>
}
export async function getStaticProps () {
@@ -18,7 +18,7 @@ export async function getStaticProps () {
// 处理分页
const page = 1
let postsToShow = []
let postsToShow
if (BLOG.postListStyle !== 'page') {
postsToShow = Array.from(allPosts)
} else {

View File

@@ -1,10 +1,10 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import { PageLayout } from '@/themes'
import { LayoutPage } from '@/themes'
const Page = (props) => {
return <PageLayout {...props} />
return <LayoutPage {...props} />
}
export async function getStaticPaths () {

View File

@@ -1,5 +1,5 @@
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import { SearchLayout } from '@/themes'
import { LayoutSearch } from '@/themes'
export async function getStaticProps () {
const {
@@ -22,7 +22,7 @@ export async function getStaticProps () {
}
const Search = (props) => {
return <SearchLayout {...props} />
return <LayoutSearch {...props} />
}
export default Search

View File

@@ -1,8 +1,8 @@
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import { TagLayout } from '@/themes'
import { LayoutTag } from '@/themes'
const Tag = (props) => {
return <TagLayout {...props} />
return <LayoutTag {...props} />
}
export async function getStaticProps ({ params }) {
@@ -37,8 +37,8 @@ export async function getStaticProps ({ params }) {
/**
* 获取所有的标签
* @param {*}} allPosts
* @returns
* @param tags
*/
function getTagNames (tags) {
const tagNames = []

View File

@@ -1,9 +1,9 @@
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import React from 'react'
import { TagIndexLayout } from '@/themes'
import { LayoutTagIndex } from '@/themes'
const TagIndex = (props) => {
return <TagIndexLayout {...props} />
return <LayoutTagIndex {...props} />
}
export async function getStaticProps () {