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