From 88d1f9811634cf279e7bfb3f711790e64b1d8e78 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 22 Mar 2022 12:51:02 +0800 Subject: [PATCH] =?UTF-8?q?empty=E4=B8=BB=E9=A2=98=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/empty/LayoutBase.js | 30 +++++++++++++++------- themes/empty/LayoutIndex.js | 36 +++++++++++++++++++++++++- themes/empty/LayoutPage.js | 50 ++++++++++++++++++++++++++++++++++--- 3 files changed, 103 insertions(+), 13 deletions(-) diff --git a/themes/empty/LayoutBase.js b/themes/empty/LayoutBase.js index 9bdf2c57..ed2de109 100644 --- a/themes/empty/LayoutBase.js +++ b/themes/empty/LayoutBase.js @@ -1,7 +1,8 @@ import CommonHead from '@/components/CommonHead' import Live2D from '@/components/Live2D' import Link from 'next/link' - +import React from 'react' +import BLOG from '@/blog.config' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -10,6 +11,9 @@ import Link from 'next/link' */ const LayoutBase = props => { const { children, meta } = props + const d = new Date() + const currentYear = d.getFullYear() + const startYear = BLOG.SINCE && BLOG.SINCE !== currentYear && BLOG.SINCE + '-' return (
@@ -19,12 +23,6 @@ const LayoutBase = props => { 首页 - - 分类 - - - 标签 -
{/* 内容主体 */} @@ -32,9 +30,23 @@ const LayoutBase = props => {
{children}
- ) } diff --git a/themes/empty/LayoutIndex.js b/themes/empty/LayoutIndex.js index 39072ba2..817bcdfb 100644 --- a/themes/empty/LayoutIndex.js +++ b/themes/empty/LayoutIndex.js @@ -1,8 +1,20 @@ +import BLOG from '@/blog.config' +import { useGlobal } from '@/lib/global' import Link from 'next/link' +import { useRouter } from 'next/router' import LayoutBase from './LayoutBase' export const LayoutIndex = props => { - const { posts } = props + const { posts, postCount } = props + + const { locale } = useGlobal() + const router = useRouter() + const totalPage = Math.ceil(postCount / BLOG.POSTS_PER_PAGE) + + const page = 1 + const showNext = page < totalPage && posts.length === BLOG.POSTS_PER_PAGE && posts.length < postCount + + const currentPage = +page return ( {posts.map(p => ( @@ -13,6 +25,28 @@ export const LayoutIndex = props => {
{p.summary}
))} + +
) } diff --git a/themes/empty/LayoutPage.js b/themes/empty/LayoutPage.js index 661a104b..2f5f795a 100644 --- a/themes/empty/LayoutPage.js +++ b/themes/empty/LayoutPage.js @@ -1,8 +1,52 @@ +import BLOG from '@/blog.config' +import { useGlobal } from '@/lib/global' +import Link from 'next/link' +import { useRouter } from 'next/router' import LayoutBase from './LayoutBase' export const LayoutPage = (props) => { const { page } = props - return - Page - {page} - + const { posts, postCount } = props + + const { locale } = useGlobal() + const router = useRouter() + const totalPage = Math.ceil(postCount / BLOG.POSTS_PER_PAGE) + + const showNext = page < totalPage && posts.length === BLOG.POSTS_PER_PAGE && posts.length < postCount + + const currentPage = +page + return ( + + {posts.map(p => ( +
+ + {p.title} + +
{p.summary}
+
+ ))} + + +
+ ) }