From 9494daee3618a55de79c1f5808bcd07379f84c22 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 6 Mar 2024 12:41:54 +0800 Subject: [PATCH] =?UTF-8?q?simple=E4=B8=BB=E9=A2=98=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=96=87=E7=AB=A0=E6=8E=A8=E8=8D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/simple/components/RecommendPosts.js | 32 ++++++++++++++++++ themes/simple/components/SideBar.js | 8 ----- themes/simple/config.js | 2 ++ themes/simple/index.js | 8 +++-- themes/starter/style.js | 38 +++++++++++----------- 5 files changed, 59 insertions(+), 29 deletions(-) create mode 100644 themes/simple/components/RecommendPosts.js diff --git a/themes/simple/components/RecommendPosts.js b/themes/simple/components/RecommendPosts.js new file mode 100644 index 00000000..fd214fa0 --- /dev/null +++ b/themes/simple/components/RecommendPosts.js @@ -0,0 +1,32 @@ +import Link from 'next/link' +import { useGlobal } from '@/lib/global' +import CONFIG from '../config' +import { siteConfig } from '@/lib/config' + +/** + * 展示文章推荐 + */ +const RecommendPosts = ({ recommendPosts }) => { + const { locale } = useGlobal() + if (!siteConfig('SIMPLE_ARTICLE_RECOMMEND_POSTS', null, CONFIG) || !recommendPosts || recommendPosts.length < 1) { + return <> + } + + return ( +
+
{locale.COMMON.RELATE_POSTS} :
+ +
+ ) +} +export default RecommendPosts diff --git a/themes/simple/components/SideBar.js b/themes/simple/components/SideBar.js index 3f109cb9..1f4fa2e3 100644 --- a/themes/simple/components/SideBar.js +++ b/themes/simple/components/SideBar.js @@ -13,22 +13,14 @@ export default function SideBar (props) { const { notice } = props return (<> - - - - ) } diff --git a/themes/simple/config.js b/themes/simple/config.js index bbacb396..bc0b8fc4 100644 --- a/themes/simple/config.js +++ b/themes/simple/config.js @@ -11,6 +11,8 @@ const CONFIG = { SIMPLE_POST_COVER_ENABLE: process.env.NEXT_PUBLIC_SIMPLE_POST_COVER_ENABLE || false, // 是否展示博客封面 + SIMPLE_ARTICLE_RECOMMEND_POSTS: process.env.NEXT_PUBLIC_SIMPLE_ARTICLE_RECOMMEND_POSTS || true, // 文章详情底部显示推荐 + // 菜单配置 SIMPLE_MENU_CATEGORY: true, // 显示分类 SIMPLE_MENU_TAG: true, // 显示标签 diff --git a/themes/simple/index.js b/themes/simple/index.js index 02cb8dd4..60867451 100644 --- a/themes/simple/index.js +++ b/themes/simple/index.js @@ -31,6 +31,7 @@ const Footer = dynamic(() => import('./components/Footer'), { ssr: false }); const SearchInput = dynamic(() => import('./components/SearchInput'), { ssr: false }); const WWAds = dynamic(() => import('@/components/WWAds'), { ssr: false }); const BlogListPage = dynamic(() => import('./components/BlogListPage'), { ssr: false }) +const RecommendPosts = dynamic(() => import('./components/RecommendPosts'), { ssr: false }) // 主题全局状态 const ThemeGlobalSimple = createContext() @@ -175,7 +176,7 @@ const LayoutArchive = props => { * @returns */ const LayoutSlug = props => { - const { post, lock, validPassword, prev, next } = props + const { post, lock, validPassword, prev, next, recommendPosts } = props const { fullWidth } = useGlobal() return ( @@ -201,7 +202,10 @@ const LayoutSlug = props => { {/* 广告嵌入 */} - {post?.type === 'Post' && } + {post?.type === 'Post' && <> + + + } {/* 评论区 */} diff --git a/themes/starter/style.js b/themes/starter/style.js index c176c16d..cfe51df6 100644 --- a/themes/starter/style.js +++ b/themes/starter/style.js @@ -8,7 +8,7 @@ const Style = () => { return