From 665b579767e4bdad3e093ad554a57e814e06b489 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 15 Feb 2022 16:10:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8D=E8=92=9C=E5=AD=90?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E9=98=85=E8=AF=BB=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Medium/LayoutSlug.js | 147 ++++++++++++++++++++++-------------- 1 file changed, 90 insertions(+), 57 deletions(-) diff --git a/themes/Medium/LayoutSlug.js b/themes/Medium/LayoutSlug.js index 366049e7..79e20588 100644 --- a/themes/Medium/LayoutSlug.js +++ b/themes/Medium/LayoutSlug.js @@ -6,7 +6,13 @@ import 'prismjs/components/prism-javascript' import 'prismjs/components/prism-markup' import 'prismjs/components/prism-python' import 'prismjs/components/prism-typescript' -import { Code, Collection, CollectionRow, Equation, NotionRenderer } from 'react-notion-x' +import { + Code, + Collection, + CollectionRow, + Equation, + NotionRenderer +} from 'react-notion-x' import LayoutBase from './LayoutBase' import Comment from '@/components/Comment' import Image from 'next/image' @@ -17,12 +23,14 @@ import mediumZoom from 'medium-zoom' import React, { useEffect, useRef } from 'react' import ArticleAround from './components/ArticleAround' import Catalog from './components/Catalog' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faEye } from '@fortawesome/free-solid-svg-icons' const mapPageUrl = id => { return 'https://www.notion.so/' + id.replace(/-/g, '') } -export const LayoutSlug = (props) => { +export const LayoutSlug = props => { const { post, prev, next } = props const meta = { title: `${post.title} | ${BLOG.TITLE}`, @@ -36,13 +44,18 @@ export const LayoutSlug = (props) => { post.toc = getPageTableOfContents(post, post.blockMap) } const { locale } = useGlobal() - const date = formatDate(post?.date?.start_date || post.createdTime, locale.LOCALE) + const date = formatDate( + post?.date?.start_date || post.createdTime, + locale.LOCALE + ) - const zoom = typeof window !== 'undefined' && mediumZoom({ - container: '.notion-viewport', - background: 'rgba(0, 0, 0, 0.2)', - margin: getMediumZoomMargin() - }) + const zoom = + typeof window !== 'undefined' && + mediumZoom({ + container: '.notion-viewport', + background: 'rgba(0, 0, 0, 0.2)', + margin: getMediumZoomMargin() + }) const zoomRef = useRef(zoom ? zoom.clone() : null) useEffect(() => { @@ -51,62 +64,82 @@ export const LayoutSlug = (props) => { const imgList = container?.getElementsByTagName('img') if (imgList && zoomRef.current) { for (let i = 0; i < imgList.length; i++) { - (zoomRef.current).attach(imgList[i]) + zoomRef.current.attach(imgList[i]) } } }) - const slotRight = post?.toc && post?.toc?.length > 3 &&
+ const slotRight = post?.toc && post?.toc?.length > 3 && ( +
+ +
+ ) - return -

{post?.title}

-
- - <> - {BLOG.AUTHOR} +

{post?.title}

+
+ + <> + {BLOG.AUTHOR} +
+ {BLOG.AUTHOR} +
+ + +
{date}
+
+ +   + +
+
+ {/* Notion文章主体 */} +
+ {post.blockMap && ( + -
{BLOG.AUTHOR}
- - -
{date}
-
- {/* Notion文章主体 */} -
- {post.blockMap && ( - - )} -
+ )} +
-
- {/* 文章内嵌广告 */} - -
-
- - -
-
+
+ {/* 文章内嵌广告 */} + +
+
+ + +
+ + ) } function getMediumZoomMargin () {