From 9d1e9b151f4c62f6dce2305b61fd27f74908b979 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 16 Feb 2022 13:59:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E3=80=81=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Medium/LayoutBase.js | 4 ++-- themes/Medium/LayoutCategory.js | 7 ++++++- themes/Medium/LayoutSlug.js | 9 +++++++++ themes/Medium/LayoutTag.js | 7 ++++++- themes/Medium/components/BlogPostCard.js | 12 ++++++++++-- themes/Medium/components/CategoryGroup.js | 15 +++------------ themes/Medium/components/CategoryItem.js | 16 ++++++++++++++++ themes/Medium/config_medium.js | 7 ++++++- 8 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 themes/Medium/components/CategoryItem.js diff --git a/themes/Medium/LayoutBase.js b/themes/Medium/LayoutBase.js index 087d2589..b0519c52 100644 --- a/themes/Medium/LayoutBase.js +++ b/themes/Medium/LayoutBase.js @@ -9,7 +9,6 @@ import TopNavBar from './components/TopNavBar' import SearchInput from './components/SearchInput' import BottomMenuBar from './components/BottomMenuBar' import { useGlobal } from '@/lib/global' -import JumpToTopButton from './components/JumpToTopButton' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -18,7 +17,7 @@ import JumpToTopButton from './components/JumpToTopButton' * @constructor */ const LayoutBase = props => { - const { children, meta, showInfoCard = true, slotRight } = props + const { children, meta, showInfoCard = true, slotRight, slotTop } = props const { locale } = useGlobal() return ( @@ -32,6 +31,7 @@ const LayoutBase = props => { {/* 移动端顶部菜单 */}
+ {slotTop} {children}
diff --git a/themes/Medium/LayoutCategory.js b/themes/Medium/LayoutCategory.js index 070184d0..34d76d23 100644 --- a/themes/Medium/LayoutCategory.js +++ b/themes/Medium/LayoutCategory.js @@ -1,8 +1,13 @@ import LayoutBase from './LayoutBase' import BlogPostListScroll from './components/BlogPostListScroll' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faTh } from '@fortawesome/free-solid-svg-icons' export const LayoutCategory = (props) => { - return + const { category } = props + const slotTop =
分类:
{category}
+ + return } diff --git a/themes/Medium/LayoutSlug.js b/themes/Medium/LayoutSlug.js index 79e20588..8c5a441d 100644 --- a/themes/Medium/LayoutSlug.js +++ b/themes/Medium/LayoutSlug.js @@ -25,6 +25,9 @@ import ArticleAround from './components/ArticleAround' import Catalog from './components/Catalog' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faEye } from '@fortawesome/free-solid-svg-icons' +import CategoryItem from './components/CategoryItem' +import TagItemMini from './components/TagItemMini' +import CONFIG_MEDIUM from './config_medium' const mapPageUrl = id => { return 'https://www.notion.so/' + id.replace(/-/g, '') @@ -135,6 +138,12 @@ export const LayoutSlug = props => { />
+
+ { CONFIG_MEDIUM.POST_DETAIL_CATEGORY && } +
+ { CONFIG_MEDIUM.POST_DETAIL_TAG && post?.tagItems?.map(tag => )} +
+
diff --git a/themes/Medium/LayoutTag.js b/themes/Medium/LayoutTag.js index fe99c6b0..042daf1c 100644 --- a/themes/Medium/LayoutTag.js +++ b/themes/Medium/LayoutTag.js @@ -1,8 +1,13 @@ import LayoutBase from './LayoutBase' import BlogPostListScroll from './components/BlogPostListScroll' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faTag } from '@fortawesome/free-solid-svg-icons' export const LayoutTag = (props) => { - return + const { tag } = props + const slotTop =
标签:
{tag}
+ + return } diff --git a/themes/Medium/components/BlogPostCard.js b/themes/Medium/components/BlogPostCard.js index ee9014e5..f2c93a7c 100644 --- a/themes/Medium/components/BlogPostCard.js +++ b/themes/Medium/components/BlogPostCard.js @@ -6,6 +6,8 @@ import Link from 'next/link' import React from 'react' import { Code, Collection, Equation, NotionRenderer } from 'react-notion-x' import CONFIG_MEDIUM from '../config_medium' +import CategoryItem from './CategoryItem' +import TagItemMini from './TagItemMini' const BlogPostCard = ({ post, showSummary }) => { const showPreview = CONFIG_MEDIUM.POST_LIST_PREVIEW && post.blockMap @@ -20,8 +22,14 @@ const BlogPostCard = ({ post, showSummary }) => { -
- {post.date.start_date} +
+
{post.date.start_date}
+ { CONFIG_MEDIUM.POST_LIST_CATEGORY && } + { CONFIG_MEDIUM.POST_LIST_TAG && post?.tagItems?.map(tag => )} +
+ +
+
{(!showPreview || showSummary) &&

diff --git a/themes/Medium/components/CategoryGroup.js b/themes/Medium/components/CategoryGroup.js index 6a1d040b..8e6b367e 100644 --- a/themes/Medium/components/CategoryGroup.js +++ b/themes/Medium/components/CategoryGroup.js @@ -1,7 +1,7 @@ -import { faFolder, faFolderOpen, faTag, faTh } from '@fortawesome/free-solid-svg-icons' +import { faTh } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import Link from 'next/link' import React from 'react' +import CategoryItem from './CategoryItem' const CategoryGroup = ({ currentCategory, categories }) => { if (!categories) { @@ -12,16 +12,7 @@ const CategoryGroup = ({ currentCategory, categories }) => {

{Object.keys(categories).map(category => { const selected = currentCategory === category - return - -
{category}({categories[category]}) -
-
- + return })}
diff --git a/themes/Medium/components/CategoryItem.js b/themes/Medium/components/CategoryItem.js new file mode 100644 index 00000000..4bb69839 --- /dev/null +++ b/themes/Medium/components/CategoryItem.js @@ -0,0 +1,16 @@ +import Link from 'next/link' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faFolderOpen, faFolder } from '@fortawesome/free-solid-svg-icons' + +export default function CategoryItem ({ key, selected, category, categoryCount }) { + return + +
{category} {categoryCount && ({ categoryCount })} +
+
+ +} diff --git a/themes/Medium/config_medium.js b/themes/Medium/config_medium.js index e61b1982..23d6ac52 100644 --- a/themes/Medium/config_medium.js +++ b/themes/Medium/config_medium.js @@ -1,7 +1,12 @@ const CONFIG_MEDIUM = { POST_LIST_COVER: true, // 文章列表显示图片封面 - POST_LIST_PREVIEW: true, // 显示文章预览 + POST_LIST_PREVIEW: true, // 列表显示文章预览 + POST_LIST_CATEGORY: true, // 列表显示文章分类 + POST_LIST_TAG: true, // 列表显示文章标签 + + POST_DETAIL_CATEGORY: true, // 文章显示分类 + POST_DETAIL_TAG: true, // 文章显示标签 // 菜单 MENU_ABOUT: true, // 显示关于