mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-08 15:10:37 +00:00
@@ -12,6 +12,7 @@ const BLOG = {
|
|||||||
homeBannerImage: './bg_image.jpg', // 背景图地址
|
homeBannerImage: './bg_image.jpg', // 背景图地址
|
||||||
showPostCover: false, // 文章列表显示封面图
|
showPostCover: false, // 文章列表显示封面图
|
||||||
showPreview: true, // 列表展示文章预览
|
showPreview: true, // 列表展示文章预览
|
||||||
|
previewLines: 12, // 预览文章的篇幅
|
||||||
showSummary: false // 显示用户自定义摘要
|
showSummary: false // 显示用户自定义摘要
|
||||||
},
|
},
|
||||||
lang: 'zh-CN', // ['zh-CN','en-US'] default lang => see /lib/lang.js for more.
|
lang: 'zh-CN', // ['zh-CN','en-US'] default lang => see /lib/lang.js for more.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ const BlogPostCard = ({ post, showSummary }) => {
|
|||||||
|
|
||||||
<div className='article-cover pointer-events-none'>
|
<div className='article-cover pointer-events-none'>
|
||||||
<Link href={`${BLOG.path}/article/${post.slug}`} passHref>
|
<Link href={`${BLOG.path}/article/${post.slug}`} passHref>
|
||||||
<a className='hover:bg-opacity-100 hover:scale-105 transform duration-300 rounded-md p-2 text-red-500 cursor-pointer'>
|
<a className='hover:bg-opacity-100 hover:scale-105 pointer-events-auto transform duration-300 rounded-md p-2 text-red-500 cursor-pointer'>
|
||||||
{locale.COMMON.ARTICLE_DETAIL}
|
{locale.COMMON.ARTICLE_DETAIL}
|
||||||
<FontAwesomeIcon className='ml-1' icon={faAngleRight} /></a>
|
<FontAwesomeIcon className='ml-1' icon={faAngleRight} /></a>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
} from '@/lib/notion'
|
} from '@/lib/notion'
|
||||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||||
import Custom404 from '@/pages/404'
|
import Custom404 from '@/pages/404'
|
||||||
import { getPageTableOfContents } from 'notion-utils'
|
|
||||||
import 'prismjs'
|
import 'prismjs'
|
||||||
import 'prismjs/components/prism-bash'
|
import 'prismjs/components/prism-bash'
|
||||||
import 'prismjs/components/prism-javascript'
|
import 'prismjs/components/prism-javascript'
|
||||||
@@ -21,7 +20,7 @@ import React from 'react'
|
|||||||
* @param {*} param0
|
* @param {*} param0
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const About = ({ post, blockMap, tags, prev, next, postCount, categories }) => {
|
const About = ({ post, tags, prev, next, postCount, categories }) => {
|
||||||
if (!post) {
|
if (!post) {
|
||||||
return <Custom404 />
|
return <Custom404 />
|
||||||
}
|
}
|
||||||
@@ -42,7 +41,7 @@ const About = ({ post, blockMap, tags, prev, next, postCount, categories }) => {
|
|||||||
postCount={postCount}
|
postCount={postCount}
|
||||||
categories={categories}
|
categories={categories}
|
||||||
>
|
>
|
||||||
<ArticleDetail post={post} blockMap={blockMap} prev={prev} next={next} />
|
<ArticleDetail post={post} prev={prev} next={next} />
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -56,20 +55,14 @@ export async function getStaticProps () {
|
|||||||
return { props: {}, revalidate: 1 }
|
return { props: {}, revalidate: 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
const blockMap = await getPostBlocks(post.id, 'slug')
|
post.blockMap = await getPostBlocks(post.id, 'slug')
|
||||||
post.toc = []
|
|
||||||
if (blockMap) {
|
|
||||||
post.blockMap = blockMap
|
|
||||||
post.content = Object.keys(blockMap.block)
|
|
||||||
post.toc = getPageTableOfContents(post, blockMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
const index = allPosts.indexOf(post)
|
const index = allPosts.indexOf(post)
|
||||||
const prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0]
|
const prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0]
|
||||||
const next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0]
|
const next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: { post, blockMap, tags, prev, next, categories, postCount, latestPosts },
|
props: { post, tags, prev, next, categories, postCount, latestPosts },
|
||||||
revalidate: 1
|
revalidate: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ const Slug = ({
|
|||||||
|
|
||||||
const drawerRight = useRef(null)
|
const drawerRight = useRef(null)
|
||||||
const targetRef = typeof window !== 'undefined' ? document.getElementById('container') : null
|
const targetRef = typeof window !== 'undefined' ? document.getElementById('container') : null
|
||||||
|
post.content = Object.keys(post?.blockMap?.block)
|
||||||
|
post.toc = getPageTableOfContents(post, post.blockMap)
|
||||||
const floatSlot = post?.toc?.length > 1 ? <div className="block lg:hidden"><TocDrawerButton onClick={() => { drawerRight?.current?.handleSwitchVisible() }} /></div> : null
|
const floatSlot = post?.toc?.length > 1 ? <div className="block lg:hidden"><TocDrawerButton onClick={() => { drawerRight?.current?.handleSwitchVisible() }} /></div> : null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -95,13 +97,7 @@ export async function getStaticProps ({ params: { slug } }) {
|
|||||||
return { props: {}, revalidate: 1 }
|
return { props: {}, revalidate: 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
const blockMap = await getPostBlocks(post.id, 'slug')
|
post.blockMap = await getPostBlocks(post.id, 'slug')
|
||||||
if (blockMap) {
|
|
||||||
post.blockMap = blockMap
|
|
||||||
post.content = Object.keys(blockMap.block)
|
|
||||||
post.toc = getPageTableOfContents(post, blockMap)
|
|
||||||
delete post.content
|
|
||||||
}
|
|
||||||
|
|
||||||
// 上一篇、下一篇文章关联
|
// 上一篇、下一篇文章关联
|
||||||
const index = allPosts.indexOf(post)
|
const index = allPosts.indexOf(post)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export async function getStaticProps () {
|
|||||||
)
|
)
|
||||||
for (const i in postsToShow) {
|
for (const i in postsToShow) {
|
||||||
const post = postsToShow[i]
|
const post = postsToShow[i]
|
||||||
const blockMap = await getPostBlocks(post.id, 'slug', 12)
|
const blockMap = await getPostBlocks(post.id, 'slug', BLOG.home.previewLines)
|
||||||
if (blockMap) {
|
if (blockMap) {
|
||||||
post.blockMap = blockMap
|
post.blockMap = blockMap
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export async function getStaticProps ({ params: { page } }) {
|
|||||||
|
|
||||||
for (const i in postsToShow) {
|
for (const i in postsToShow) {
|
||||||
const post = postsToShow[i]
|
const post = postsToShow[i]
|
||||||
const blockMap = await getPostBlocks(post.id, 'slug', 12)
|
const blockMap = await getPostBlocks(post.id, 'slug', BLOG.home.previewLines)
|
||||||
if (blockMap) {
|
if (blockMap) {
|
||||||
post.blockMap = blockMap
|
post.blockMap = blockMap
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user