mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-01 23:16:51 +00:00
动态页面展示;
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Layout404 } from '@/themes'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
/**
|
||||
* 自定义404界面
|
||||
@@ -7,5 +7,7 @@ import { Layout404 } from '@/themes'
|
||||
*/
|
||||
|
||||
export default function Custom404 (props) {
|
||||
return <Layout404 {...props}/>
|
||||
const { ThemeComponents } = useGlobal()
|
||||
|
||||
return <ThemeComponents.Layout404 {...props}/>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import BLOG from '@/blog.config'
|
||||
import { getPostBlocks } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { LayoutSlug } from '@/themes'
|
||||
import Custom404 from '@/pages/404'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import Custom404 from './404'
|
||||
|
||||
/**
|
||||
* 根据notion的slug访问页面,针对类型为Page的页面
|
||||
@@ -10,10 +10,11 @@ import Custom404 from '@/pages/404'
|
||||
* @returns
|
||||
*/
|
||||
const Slug = (props) => {
|
||||
const { ThemeComponents } = useGlobal()
|
||||
if (!props.post) {
|
||||
return <Custom404 {...props} />
|
||||
}
|
||||
return <LayoutSlug {...props} showArticleInfo={false}/>
|
||||
return <ThemeComponents.LayoutSlug {...props} showArticleInfo={false}/>
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import React from 'react'
|
||||
import { LayoutArchive } from '@/themes'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
const ArchiveIndex = (props) => {
|
||||
const { ThemeComponents } = useGlobal()
|
||||
return <ThemeComponents.LayoutArchive {...props}/>
|
||||
}
|
||||
|
||||
export async function getStaticProps () {
|
||||
const { allPosts, categories, tags, postCount, customNav } =
|
||||
@@ -18,8 +23,4 @@ export async function getStaticProps () {
|
||||
}
|
||||
}
|
||||
|
||||
const ArchiveIndex = (props) => {
|
||||
return <LayoutArchive {...props}/>
|
||||
}
|
||||
|
||||
export default ArchiveIndex
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import BLOG from '@/blog.config'
|
||||
import { getPostBlocks } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { LayoutSlug } from '@/themes'
|
||||
import Custom404 from '@/pages/404'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import Custom404 from '../404'
|
||||
|
||||
/**
|
||||
* 根据notion的slug访问页面
|
||||
@@ -10,10 +10,11 @@ import Custom404 from '@/pages/404'
|
||||
* @returns
|
||||
*/
|
||||
const Slug = (props) => {
|
||||
const { ThemeComponents } = useGlobal()
|
||||
if (!props.post) {
|
||||
return <Custom404 {...props} />
|
||||
}
|
||||
return <LayoutSlug {...props} showArticleInfo={true}/>
|
||||
return <ThemeComponents.LayoutSlug {...props} showArticleInfo={true}/>
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import React from 'react'
|
||||
import { LayoutCategory } from '@/themes'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
export default function Category (props) {
|
||||
return <LayoutCategory {...props} />
|
||||
const { ThemeComponents } = useGlobal()
|
||||
return <ThemeComponents.LayoutCategory {...props} />
|
||||
}
|
||||
|
||||
export async function getStaticProps ({ params }) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import React from 'react'
|
||||
import { LayoutCategoryIndex } from '@/themes'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
export default function Category (props) {
|
||||
return <LayoutCategoryIndex {...props}/>
|
||||
const { ThemeComponents } = useGlobal()
|
||||
return <ThemeComponents.LayoutCategoryIndex {...props}/>
|
||||
}
|
||||
|
||||
export async function getStaticProps () {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import BLOG from '@/blog.config'
|
||||
import { getPostBlocks } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { LayoutIndex, THEME_CONFIG, ThemeMap } from '@/themes'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
const Index = (props) => {
|
||||
const { theme } = useGlobal()
|
||||
console.log('模板', ThemeMap[theme].LayoutIndex)
|
||||
return <LayoutIndex {...props}/>
|
||||
const { ThemeComponents } = useGlobal()
|
||||
return <ThemeComponents.LayoutIndex {...props}/>
|
||||
}
|
||||
|
||||
export async function getStaticProps () {
|
||||
@@ -29,7 +27,7 @@ export async function getStaticProps () {
|
||||
BLOG.POSTS_PER_PAGE * (page - 1),
|
||||
BLOG.POSTS_PER_PAGE * page
|
||||
)
|
||||
if (THEME_CONFIG.POST_LIST_PREVIEW || BLOG.POST_LIST_PREVIEW) {
|
||||
if (BLOG.POST_LIST_PREVIEW) {
|
||||
for (const i in postsToShow) {
|
||||
const post = postsToShow[i]
|
||||
const blockMap = await getPostBlocks(post.id, 'slug', BLOG.POST_PREVIEW_LINES)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import BLOG from '@/blog.config'
|
||||
import { getPostBlocks } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { LayoutPage, THEME_CONFIG } from '@/themes'
|
||||
import Custom404 from '@/pages/404'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
const Page = (props) => {
|
||||
const { ThemeComponents } = useGlobal()
|
||||
if (!props?.meta) {
|
||||
return <Custom404 {...props} />
|
||||
return <ThemeComponents.Custom404 {...props} />
|
||||
}
|
||||
return <LayoutPage {...props} />
|
||||
return <ThemeComponents.LayoutPage {...props} />
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
@@ -43,8 +43,7 @@ export async function getStaticProps ({ params: { page } }) {
|
||||
BLOG.POSTS_PER_PAGE * (page - 1),
|
||||
BLOG.POSTS_PER_PAGE * page
|
||||
)
|
||||
// 加载预览
|
||||
if (THEME_CONFIG.POST_LIST_PREVIEW || BLOG.POST_LIST_PREVIEW) {
|
||||
if (BLOG.POST_LIST_PREVIEW) {
|
||||
for (const i in postsToShow) {
|
||||
const post = postsToShow[i]
|
||||
const blockMap = await getPostBlocks(post.id, 'slug', BLOG.POST_PREVIEW_LINES)
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { LayoutSearch } from '@/themes'
|
||||
import BLOG from '@/blog.config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { getDataFromCache } from '@/lib/cache/cache_manager'
|
||||
|
||||
const Index = (props) => {
|
||||
const { keyword } = props
|
||||
const { locale } = useGlobal()
|
||||
const meta = {
|
||||
title: `${keyword || ''} | ${locale.NAV.SEARCH} | ${BLOG.TITLE} `,
|
||||
description: BLOG.DESCRIPTION,
|
||||
type: 'website'
|
||||
}
|
||||
|
||||
const { ThemeComponents } = useGlobal()
|
||||
return <ThemeComponents.LayoutSearch {...props} meta={meta} currentSearch={keyword} />
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端搜索
|
||||
* @param {*} param0
|
||||
@@ -33,17 +45,6 @@ export async function getServerSideProps ({ params: { keyword } }) {
|
||||
}
|
||||
}
|
||||
|
||||
const Index = (props) => {
|
||||
const { keyword } = props
|
||||
const { locale } = useGlobal()
|
||||
const meta = {
|
||||
title: `${keyword || ''} | ${locale.NAV.SEARCH} | ${BLOG.TITLE} `,
|
||||
description: BLOG.DESCRIPTION,
|
||||
type: 'website'
|
||||
}
|
||||
return <LayoutSearch {...props} meta={meta} currentSearch={keyword} />
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象的指定字段拼接到字符串
|
||||
* @param sourceTextArray
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { LayoutSearch } from '@/themes'
|
||||
import BLOG from '@/blog.config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { useRouter } from 'next/router'
|
||||
@@ -51,7 +50,10 @@ const Search = (props) => {
|
||||
description: BLOG.DESCRIPTION,
|
||||
type: 'website'
|
||||
}
|
||||
return <LayoutSearch {...props} posts={filteredPosts} meta={meta} currentSearch={searchKey} />
|
||||
|
||||
const { ThemeComponents } = useGlobal()
|
||||
|
||||
return <ThemeComponents.LayoutSearch {...props} posts={filteredPosts} meta={meta} currentSearch={searchKey} />
|
||||
}
|
||||
|
||||
function getSearchKey () {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { LayoutTag } from '@/themes'
|
||||
|
||||
const Tag = (props) => {
|
||||
return <LayoutTag {...props} />
|
||||
const { ThemeComponents } = useGlobal()
|
||||
return <ThemeComponents.LayoutTag {...props} />
|
||||
}
|
||||
|
||||
export async function getStaticProps ({ params }) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import React from 'react'
|
||||
import { LayoutTagIndex } from '@/themes'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
const TagIndex = (props) => {
|
||||
return <LayoutTagIndex {...props} />
|
||||
const { ThemeComponents } = useGlobal()
|
||||
return <ThemeComponents.LayoutTagIndex {...props} />
|
||||
}
|
||||
|
||||
export async function getStaticProps () {
|
||||
|
||||
Reference in New Issue
Block a user