From 8f9d3c45e794d2036fbb613a591692c6d287051c Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 4 Nov 2021 10:11:03 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20[=E5=88=A0=E9=99=A4=E6=97=A7?= =?UTF-8?q?=E5=88=86=E9=A1=B5page.js]=E4=BF=9D=E7=95=99=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E5=88=86=E9=A1=B5=EF=BC=9B=20=E4=BF=AE=E5=A4=8D=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=A1=B5=E4=B8=8D=E9=87=8D=E7=BD=AEbug;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SearchInput.js | 10 ++++---- pages/article/[slug].js | 4 +-- pages/index.js | 2 +- pages/page/[page].js | 53 --------------------------------------- 4 files changed, 8 insertions(+), 61 deletions(-) delete mode 100644 pages/page/[page].js diff --git a/components/SearchInput.js b/components/SearchInput.js index 03519aa4..18bd9d29 100644 --- a/components/SearchInput.js +++ b/components/SearchInput.js @@ -1,6 +1,6 @@ import React, { useState } from 'react' import { useLocale } from '@/lib/locale' -import Router, { useRouter } from 'next/router' +import { useRouter } from 'next/router' const SearchInput = ({ currentTag }) => { const locale = useLocale() @@ -8,12 +8,12 @@ const SearchInput = ({ currentTag }) => { const [searchValue, setSearchValue] = useState('') const handleSearch = () => { if (searchValue && searchValue !== '') { - Router.push({ pathname: '/page/1', query: { s: searchValue } }).then(r => { - console.log(r) + router.push({ pathname: '/', query: { s: searchValue } }).then(r => { + router.reload() }) } else { - Router.push({ pathname: '/' }).then(r => { - console.log(r) + router.push({ pathname: '/' }).then(r => { + router.reload() }) } } diff --git a/pages/article/[slug].js b/pages/article/[slug].js index ff0cf109..ac6f9371 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -43,7 +43,7 @@ const BlogPost = ({ post, blockMap, tags, prev, next, posts }) => { {/* 阅读进度条 */} -
+
{/* 中央区域 wrapper */}
@@ -55,7 +55,7 @@ const BlogPost = ({ post, blockMap, tags, prev, next, posts }) => {
+ className='shadow mb-20 w-screen md:w-full overflow-x-auto md:px-10 px-5 py-10 max-w-5xl mx-auto dark:border-gray-700 bg-white dark:bg-gray-700'> {/* 文章标题 */}

{post.title} diff --git a/pages/index.js b/pages/index.js index 2085b2c7..0362c321 100644 --- a/pages/index.js +++ b/pages/index.js @@ -28,7 +28,7 @@ export async function getStaticProps () { const Index = ({ posts, tags, meta }) => { return ( -
+
diff --git a/pages/page/[page].js b/pages/page/[page].js deleted file mode 100644 index a9f62fe1..00000000 --- a/pages/page/[page].js +++ /dev/null @@ -1,53 +0,0 @@ -import { getAllPosts, getAllTags } from '@/lib/notion' -import BLOG from '@/blog.config' -import BaseLayout from '@/layouts/BaseLayout' -import TagsBar from '@/components/TagsBar' -import BlogPostList from '@/components/BlogPostList' - -const Page = ({ posts, tags, page }) => { - const meta = { - title: `${BLOG.title} | 博客列表`, - description: BLOG.description, - type: 'website' - } - return -
- - -
-
-} - -export async function getStaticPaths () { - let posts = await getAllPosts({ from: 'page-path' }) - posts = posts.filter( - post => post.status[0] === 'Published' && post.type[0] === 'Post' - ) - const totalPosts = posts.length - const totalPages = Math.ceil(totalPosts / BLOG.postsPerPage) - return { - paths: Array.from({ length: totalPages - 1 }, (_, i) => ({ - params: { page: '' + (i + 1) } - })), - fallback: true - } -} - -export async function getStaticProps (context) { - const { page } = context.params // Get Current Page No. - let posts = await getAllPosts({ from: 'page-props' }) - posts = posts.filter( - post => post.status[0] === 'Published' && post.type[0] === 'Post' - ) - const tags = await getAllTags(posts) - return { - props: { - tags, - posts, - page - }, - revalidate: 1 - } -} - -export default Page