From 7480cef80536ea00d34a4692431a33de53333fa8 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 18 Oct 2021 14:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9D=A1=E3=80=81=E5=9B=9E?= =?UTF-8?q?=E9=A1=B6=E9=94=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/JumpToTop.js | 23 +++++++---------------- components/Progress.js | 4 ++-- layouts/BaseLayout.js | 2 +- pages/article/[slug].js | 34 +++++++++++++++++----------------- 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/components/JumpToTop.js b/components/JumpToTop.js index 98c5142b..d14ff486 100644 --- a/components/JumpToTop.js +++ b/components/JumpToTop.js @@ -34,23 +34,14 @@ const JumpToTop = ({ targetRef, showPercent = true }) => { return (
-
+
-
diff --git a/components/Progress.js b/components/Progress.js index 6a9c3055..30ac21d4 100644 --- a/components/Progress.js +++ b/components/Progress.js @@ -24,8 +24,8 @@ const Progress = ({ targetRef }) => { return () => document.removeEventListener('scroll', scrollListener) }, [percent]) - return (
-
+ return (
+
) } diff --git a/layouts/BaseLayout.js b/layouts/BaseLayout.js index d5de2544..a8bf9e63 100644 --- a/layouts/BaseLayout.js +++ b/layouts/BaseLayout.js @@ -52,7 +52,7 @@ const BaseLayout = ({ children, layout, fullWidth, tags, meta, post, ...customMe
{children} - +
diff --git a/pages/article/[slug].js b/pages/article/[slug].js index 191c9429..86a76189 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -19,7 +19,7 @@ import { useRef } from 'react' const mapPageUrl = id => { return 'https://www.notion.so/' + id.replace(/-/g, '') } -const BlogPost = ({ post, blockMap, emailHash, tags, prev, next }) => { +const BlogPost = ({ post, blockMap, tags, prev, next }) => { if (!post) { return
@@ -40,7 +40,8 @@ const BlogPost = ({ post, blockMap, emailHash, tags, prev, next }) => { return {/* 阅读进度条 */} -
+ +
{/* 中央区域 wrapper */}
@@ -52,7 +53,7 @@ const BlogPost = ({ post, blockMap, emailHash, tags, prev, next }) => {
+ className='w-screen md:w-full overflow-x-auto md:px-10 px-5 py-10 max-w-5xl mx-auto bg-white dark:border-gray-700 dark:bg-gray-700'> {/* 文章标题 */}

{post.title} @@ -163,19 +164,19 @@ const BlogPost = ({ post, blockMap, emailHash, tags, prev, next }) => { } export async function getStaticPaths () { - if (BLOG.isProd) { - let posts = await getAllPosts() - posts = posts.filter(post => post.status[0] === 'Published') - return { - paths: posts.map(row => `${BLOG.path}/article/${row.slug}`), - fallback: true - } - } else { - return { - paths: [], - fallback: true - } + // if (BLOG.isProd) { + let posts = await getAllPosts() + posts = posts.filter(post => post.status[0] === 'Published') + return { + paths: posts.map(row => `${BLOG.path}/article/${row.slug}`), + fallback: true } + // } else { + // return { + // paths: [], + // fallback: true + // } + // } } export async function getStaticProps ({ params: { slug } }) { @@ -190,7 +191,6 @@ export async function getStaticProps ({ params: { slug } }) { } const blockMap = await getPostBlocks(post.id) - const emailHash = createHash('md5').update(BLOG.email).digest('hex') post.toc = getPageTableOfContents(post, blockMap) posts = posts.filter(post => post.type[0] === 'Post') const tags = await getAllTags(posts) @@ -200,7 +200,7 @@ export async function getStaticProps ({ params: { slug } }) { const next = posts.slice(index + 1, index + 2)[0] ?? posts[0] return { - props: { post, blockMap, emailHash, tags, prev, next }, + props: { post, blockMap, tags, prev, next }, revalidate: 1 } }