From ef00d9d61b90169704912fcae015b3437eb209b0 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 21 Apr 2023 10:22:00 +0800 Subject: [PATCH 1/4] =?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 && ( +
+ +
+ +
+ )} +
))}
Date: Fri, 21 Apr 2023 12:20:56 +0800 Subject: [PATCH 2/4] vercel-analytics --- blog.config.js | 1 + components/CommonScript.js | 3 +++ package.json | 1 + 3 files changed, 5 insertions(+) diff --git a/blog.config.js b/blog.config.js index 4e642e4d..4d53eaff 100644 --- a/blog.config.js +++ b/blog.config.js @@ -254,6 +254,7 @@ const BLOG = { // <---- 评论插件 // ----> 站点统计 + ANALYTICS_VERCEL: process.env.NEXT_PUBLIC_ANALYTICS_VERCEL || true, // vercel自带的统计 https://vercel.com/docs/concepts/analytics/quickstart https://github.com/tangly1024/NotionNext/issues/897 ANALYTICS_BUSUANZI_ENABLE: true, // 展示网站阅读量、访问数 see http://busuanzi.ibruce.info/ ANALYTICS_BAIDU_ID: process.env.NEXT_PUBLIC_ANALYTICS_BAIDU_ID || '', // e.g 只需要填写百度统计的id,[baidu_id] -> https://hm.baidu.com/hm.js?[baidu_id] ANALYTICS_CNZZ_ID: process.env.NEXT_PUBLIC_ANALYTICS_CNZZ_ID || '', // 只需要填写站长统计的id, [cnzz_id] -> https://s9.cnzz.com/z_stat.php?id=[cnzz_id]&web_id=[cnzz_id] diff --git a/components/CommonScript.js b/components/CommonScript.js index 57adf07a..09720bc5 100644 --- a/components/CommonScript.js +++ b/components/CommonScript.js @@ -1,4 +1,5 @@ import BLOG from '@/blog.config' +import { Analytics } from '@vercel/analytics/react' /** * 第三方代码 统计脚本 @@ -7,6 +8,8 @@ import BLOG from '@/blog.config' */ const CommonScript = () => { return (<> + {BLOG.ANALYTICS_VERCEL &&
} + {BLOG.COMMENT_DAO_VOICE_ID && (<> {/* DaoVoice 反馈 */}