From ef00d9d61b90169704912fcae015b3437eb209b0 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 21 Apr 2023 10:22:00 +0800 Subject: [PATCH] =?UTF-8?q?example=E4=B8=BB=E9=A2=98=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=B0=81=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/globals.css | 8 +++ themes/example/components/BlogListPage.js | 63 +++++++++++++-------- themes/example/components/BlogListScroll.js | 59 ++++++++++++------- themes/example/config_example.js | 5 +- 4 files changed, 90 insertions(+), 45 deletions(-) diff --git a/styles/globals.css b/styles/globals.css index 972618ab..fa1f8f5d 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -302,4 +302,12 @@ a.avatar-wrapper { -webkit-line-clamp: 4; overflow: hidden; text-overflow: ellipsis; +} + +.p-3-lines { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 3; + overflow: hidden; + text-overflow: ellipsis; } \ No newline at end of file diff --git a/themes/example/components/BlogListPage.js b/themes/example/components/BlogListPage.js index c655df4a..c36ebca1 100644 --- a/themes/example/components/BlogListPage.js +++ b/themes/example/components/BlogListPage.js @@ -3,6 +3,7 @@ import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' import Link from 'next/link' +import CONFIG_EXAMPLE from '../config_example' export const BlogListPage = props => { const { page = 1, posts, postCount } = props @@ -15,38 +16,50 @@ export const BlogListPage = props => { const showNext = page < totalPage const pagePrefix = router.asPath.replace(/\/page\/[1-9]\d*/, '').replace(/\/$/, '') + const showPageCover = CONFIG_EXAMPLE.POST_LIST_COVER + return ( -
+
{posts?.map(p => ( -
-

- - {p.title} - -

+
+
+

+ + {p.title} + +

-
- by {BLOG.AUTHOR} on {p.date?.start_date || p.createdTime} - | - {p.category} - {/* | */} - {/* 2 Comments */} -
+
+ by {BLOG.AUTHOR} on {p.date?.start_date || p.createdTime} + | + {p.category} + {/* | */} + {/* 2 Comments */} +
-

- {p.summary} -

- {/* 搜索结果 */} - {p.results && ( -

- {p.results.map(r => ( - {r} - ))} +

+ {p.summary}

+ {/* 搜索结果 */} + {p.results && ( +

+ {p.results.map(r => ( + {r} + ))} +

+ )} +
+ {/* 图片封面 */} + {showPageCover && ( +
+ +
+ +
)}
))} diff --git a/themes/example/components/BlogListScroll.js b/themes/example/components/BlogListScroll.js index b3d7f3f0..0949f4da 100644 --- a/themes/example/components/BlogListScroll.js +++ b/themes/example/components/BlogListScroll.js @@ -3,6 +3,7 @@ import { useGlobal } from '@/lib/global' import Link from 'next/link' import React from 'react' import throttle from 'lodash.throttle' +import CONFIG_EXAMPLE from '../config_example' export const BlogListScroll = props => { const { posts } = props @@ -43,30 +44,50 @@ export const BlogListScroll = props => { } }) + const showPageCover = CONFIG_EXAMPLE.POST_LIST_COVER + return (
{postsToShow.map(p => ( -
-

- - {p.title} - -

+ +

+ {p.summary} +

+ {/* 搜索结果 */} + {p.results && ( +

+ {p.results.map(r => ( + {r} + ))} +

+ )} +
+ {/* 图片封面 */} + {showPageCover && ( +
+ +
+ +
+ )} +
))}