From 9234b6fb4b779512b2cf3ddefded1638dc9ac1e1 Mon Sep 17 00:00:00 2001 From: Femoon Date: Sun, 21 Apr 2024 18:22:33 +0800 Subject: [PATCH 1/6] feat: add title icon configuration --- .env.local | 1 + blog.config.js | 1 + themes/commerce/components/PostHeader.js | 2 +- themes/example/components/BlogPostCard.js | 2 +- themes/example/components/Title.js | 2 +- themes/fukasawa/components/ArticleDetail.js | 3 ++- themes/fukasawa/components/BlogCard.js | 2 +- themes/game/components/BlogPost.js | 2 +- themes/game/components/PostInfo.js | 3 ++- themes/gitbook/components/BlogPostCard.js | 2 +- themes/gitbook/index.js | 2 +- themes/heo/components/BlogPostCard.js | 2 +- themes/heo/components/PostHeader.js | 2 +- themes/hexo/components/BlogPostCardInfo.js | 2 +- themes/hexo/components/PostHeader.js | 2 +- themes/matery/components/BlogPostCard.js | 2 +- themes/matery/components/PostHeader.js | 3 ++- themes/medium/components/ArticleInfo.js | 2 +- themes/medium/components/BlogPostCard.js | 2 +- themes/movie/components/BlogPostCard.js | 2 +- themes/movie/components/Title.js | 2 +- themes/nav/components/BlogPostCard.js | 2 +- themes/nav/index.js | 2 +- themes/next/components/ArticleDetail.js | 2 +- themes/next/components/BlogPostCard.js | 2 +- themes/nobelium/components/ArticleInfo.js | 2 +- themes/nobelium/components/BlogPost.js | 2 +- themes/plog/components/ArticleInfo.js | 2 +- themes/plog/components/BlogPost.js | 3 ++- themes/simple/components/ArticleInfo.js | 2 +- themes/simple/components/BlogItem.js | 2 +- 31 files changed, 35 insertions(+), 29 deletions(-) diff --git a/.env.local b/.env.local index db9decf2520..f6509b08fb7 100644 --- a/.env.local +++ b/.env.local @@ -62,6 +62,7 @@ NEXT_PUBLIC_VERSION=4.4.3 # NEXT_PUBLIC_ALGOLIA_INDEX= # NEXT_PUBLIC_PREVIEW_CATEGORY_COUNT= # NEXT_PUBLIC_PREVIEW_TAG_COUNT= +# NEXT_PUBLIC_POST_TITLE_ICON= # NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK= # NEXT_PUBLIC_FIREWORKS= # NEXT_PUBLIC_FIREWORKS_COLOR= diff --git a/blog.config.js b/blog.config.js index abfc4cd26ef..4ec5e8fc3a1 100644 --- a/blog.config.js +++ b/blog.config.js @@ -230,6 +230,7 @@ const BLOG = { PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量,0为不限制 PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量,0为不限制 + POST_TITLE_ICON: process.env.NEXT_PUBLIC_POST_TITLE_ICON || true, // 是否显示标题icon POST_DISABLE_GALLERY_CLICK: process.env.NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK || false, // 画册视图禁止点击,方便在友链页面的画册插入链接 diff --git a/themes/commerce/components/PostHeader.js b/themes/commerce/components/PostHeader.js index e48b1f0cda4..4a258cb5582 100644 --- a/themes/commerce/components/PostHeader.js +++ b/themes/commerce/components/PostHeader.js @@ -29,7 +29,7 @@ export default function PostHeader({ post }) { {/* 文章Title */}
-
{post.title}
+ {siteConfig('POST_TITLE_ICON') && }
{post.title}
diff --git a/themes/example/components/BlogPostCard.js b/themes/example/components/BlogPostCard.js index b66dcca3f20..723f8192607 100644 --- a/themes/example/components/BlogPostCard.js +++ b/themes/example/components/BlogPostCard.js @@ -16,7 +16,7 @@ const BlogPostCard = ({ post }) => { - {post?.title} + {siteConfig('POST_TITLE_ICON') && }{post?.title} diff --git a/themes/example/components/Title.js b/themes/example/components/Title.js index 73ca9d7fd1e..a073f1cc913 100644 --- a/themes/example/components/Title.js +++ b/themes/example/components/Title.js @@ -12,7 +12,7 @@ export const Title = (props) => { const description = post?.description || siteConfig('AUTHOR') return
-

{title}

+

{siteConfig('POST_TITLE_ICON') && }{title}

{description}

diff --git a/themes/fukasawa/components/ArticleDetail.js b/themes/fukasawa/components/ArticleDetail.js index 544d80de3bd..6883d8e05a1 100644 --- a/themes/fukasawa/components/ArticleDetail.js +++ b/themes/fukasawa/components/ArticleDetail.js @@ -10,6 +10,7 @@ import LazyImage from '@/components/LazyImage' import { formatDateFmt } from '@/lib/utils/formatDate' import WWAds from '@/components/WWAds' import NotionIcon from '@/components/NotionIcon' +import { siteConfig } from '@/lib/config' /** * @@ -37,7 +38,7 @@ export default function ArticleDetail(props) { {/* 文章Title */}
- {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title}
diff --git a/themes/fukasawa/components/BlogCard.js b/themes/fukasawa/components/BlogCard.js index 0f945f77c7a..6e31efaccce 100644 --- a/themes/fukasawa/components/BlogCard.js +++ b/themes/fukasawa/components/BlogCard.js @@ -71,7 +71,7 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => { passHref href={url} className={`break-words cursor-pointer font-bold hover:underline text-xl ${showPreview ? 'justify-center' : 'justify-start'} leading-tight text-gray-700 dark:text-gray-100 hover:text-blue-500 dark:hover:text-blue-400`}> - {post.title} + {siteConfig('POST_TITLE_ICON') && } {post.title} diff --git a/themes/game/components/BlogPost.js b/themes/game/components/BlogPost.js index b5845cf905b..fbe52fdfb0f 100644 --- a/themes/game/components/BlogPost.js +++ b/themes/game/components/BlogPost.js @@ -15,7 +15,7 @@ const BlogPost = ({ post }) => {

- {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title}

- + {siteConfig('POST_TITLE_ICON') && } {post?.title}

diff --git a/themes/gitbook/components/BlogPostCard.js b/themes/gitbook/components/BlogPostCard.js index a28709730fd..352d098812c 100644 --- a/themes/gitbook/components/BlogPostCard.js +++ b/themes/gitbook/components/BlogPostCard.js @@ -14,7 +14,7 @@ const BlogPostCard = ({ post, className }) => {
- {post.title} + {siteConfig('POST_TITLE_ICON') && } {post.title}
{/* 最新文章加个红点 */} {post?.isLatest && siteConfig('GITBOOK_LATEST_POST_RED_BADGE', false, CONFIG) && } diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index 5f4169ba7ac..fb234c47339 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -275,7 +275,7 @@ const LayoutSlug = (props) => { {!lock &&
{/* title */} -

{post?.title}

+

{siteConfig('POST_TITLE_ICON') && }{post?.title}

{/* Notion文章主体 */} {post && (
diff --git a/themes/heo/components/BlogPostCard.js b/themes/heo/components/BlogPostCard.js index ab6cd1c7ce7..4d32f231c3c 100644 --- a/themes/heo/components/BlogPostCard.js +++ b/themes/heo/components/BlogPostCard.js @@ -44,7 +44,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { href={url} passHref className={' group-hover:text-indigo-700 dark:hover:text-yellow-700 dark:group-hover:text-yellow-600 text-black dark:text-gray-100 line-clamp-2 replace cursor-pointer text-xl font-extrabold leading-tight'}> - {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title} diff --git a/themes/heo/components/PostHeader.js b/themes/heo/components/PostHeader.js index 925c8040eb5..97ce4fff214 100644 --- a/themes/heo/components/PostHeader.js +++ b/themes/heo/components/PostHeader.js @@ -65,7 +65,7 @@ export default function PostHeader({ post, siteInfo }) { {/* 文章Title */}
- {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title}
{/* 标题底部补充信息 */} diff --git a/themes/hexo/components/BlogPostCardInfo.js b/themes/hexo/components/BlogPostCardInfo.js index 2232a6e8fad..5ab14856c27 100644 --- a/themes/hexo/components/BlogPostCardInfo.js +++ b/themes/hexo/components/BlogPostCardInfo.js @@ -25,7 +25,7 @@ export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary className={`line-clamp-2 replace cursor-pointer text-2xl ${showPreview ? 'text-center' : '' } leading-tight font-normal text-gray-600 dark:text-gray-100 hover:text-indigo-700 dark:hover:text-indigo-400`}> - {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title} diff --git a/themes/hexo/components/PostHeader.js b/themes/hexo/components/PostHeader.js index 6441d942f92..aa94acb9026 100644 --- a/themes/hexo/components/PostHeader.js +++ b/themes/hexo/components/PostHeader.js @@ -40,7 +40,7 @@ export default function PostHeader({ post, siteInfo }) { {/* 文章Title */}
- {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title}
diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js index 21e7b71764f..d9a9c79fd2e 100644 --- a/themes/matery/components/BlogPostCard.js +++ b/themes/matery/components/BlogPostCard.js @@ -40,7 +40,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { className="h-full w-full group-hover:scale-125 group-hover:brightness-50 brightness-90 rounded-t-md transform object-cover duration-500" />

- {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title}

diff --git a/themes/matery/components/PostHeader.js b/themes/matery/components/PostHeader.js index 9279b78c093..246f488ccc5 100644 --- a/themes/matery/components/PostHeader.js +++ b/themes/matery/components/PostHeader.js @@ -1,5 +1,6 @@ import LazyImage from '@/components/LazyImage' import NotionIcon from '@/components/NotionIcon' +import { siteConfig } from '@/lib/config' /** * 文章背景图 @@ -10,7 +11,7 @@ export default function PostHeader({ post, siteInfo }) { return ( {/* 阴影遮罩 */}

- + {siteConfig('POST_TITLE_ICON') && } {post.title}

diff --git a/themes/movie/components/Title.js b/themes/movie/components/Title.js index 73ca9d7fd1e..a073f1cc913 100644 --- a/themes/movie/components/Title.js +++ b/themes/movie/components/Title.js @@ -12,7 +12,7 @@ export const Title = (props) => { const description = post?.description || siteConfig('AUTHOR') return
-

{title}

+

{siteConfig('POST_TITLE_ICON') && }{title}

{description}

diff --git a/themes/nav/components/BlogPostCard.js b/themes/nav/components/BlogPostCard.js index 92c5fe2bc3b..56ca3c2cba9 100755 --- a/themes/nav/components/BlogPostCard.js +++ b/themes/nav/components/BlogPostCard.js @@ -14,7 +14,7 @@ const BlogPostCard = ({ post, className }) => {
- + {siteConfig('POST_TITLE_ICON') && }

{post.title}

{post.summary ? post.summary : '暂无简介'}

diff --git a/themes/nav/index.js b/themes/nav/index.js index 2b2e4973e37..c2bf7426d72 100755 --- a/themes/nav/index.js +++ b/themes/nav/index.js @@ -240,7 +240,7 @@ const LayoutSlug = (props) => { {!lock &&
{/* title */} -

{post?.title}

+

{siteConfig('POST_TITLE_ICON') && }{post?.title}

{/* Notion文章主体 */} {post && (
diff --git a/themes/next/components/ArticleDetail.js b/themes/next/components/ArticleDetail.js index 642001173e1..bdd677ef710 100644 --- a/themes/next/components/ArticleDetail.js +++ b/themes/next/components/ArticleDetail.js @@ -51,7 +51,7 @@ export default function ArticleDetail(props) { {/* title */}
- {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title}
{/* meta */} diff --git a/themes/next/components/BlogPostCard.js b/themes/next/components/BlogPostCard.js index 8b3f4a5bfa6..5c92482074d 100644 --- a/themes/next/components/BlogPostCard.js +++ b/themes/next/components/BlogPostCard.js @@ -40,7 +40,7 @@ const BlogPostCard = ({ post, index, showSummary }) => { passHref className={`cursor-pointer text-3xl ${showPreview ? 'text-center' : ''} leading-tight text-gray-700 dark:text-gray-100 hover:text-blue-500 dark:hover:text-blue-400`}> - {post.title} + {siteConfig('POST_TITLE_ICON') && } {post.title} diff --git a/themes/nobelium/components/ArticleInfo.js b/themes/nobelium/components/ArticleInfo.js index b916d8cc7a5..74a1b21dbe9 100644 --- a/themes/nobelium/components/ArticleInfo.js +++ b/themes/nobelium/components/ArticleInfo.js @@ -14,7 +14,7 @@ export const ArticleInfo = (props) => {

- {post?.title} + {siteConfig('POST_TITLE_ICON') && }{post?.title}

{post?.type !== 'Page' && <> diff --git a/themes/nobelium/components/BlogPost.js b/themes/nobelium/components/BlogPost.js index b5845cf905b..fbe52fdfb0f 100644 --- a/themes/nobelium/components/BlogPost.js +++ b/themes/nobelium/components/BlogPost.js @@ -15,7 +15,7 @@ const BlogPost = ({ post }) => {

- {post.title} + {siteConfig('POST_TITLE_ICON') && }{post.title}