From f142001009e8a7ad31e7aa8a2841ae45240e7f01 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 9 Dec 2022 09:42:40 +0800 Subject: [PATCH] =?UTF-8?q?medium=E4=B8=BB=E9=A2=98=E6=A0=B7=E5=BC=8F\?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/medium/LayoutSearch.js | 20 +++++++++++++++----- themes/medium/LayoutSlug.js | 15 +++------------ themes/medium/components/ArticleDetail.js | 21 ++++++++++----------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/themes/medium/LayoutSearch.js b/themes/medium/LayoutSearch.js index 76a9ddae..0ff29b6d 100644 --- a/themes/medium/LayoutSearch.js +++ b/themes/medium/LayoutSearch.js @@ -9,15 +9,19 @@ import BLOG from '@/blog.config' import Mark from 'mark.js' import BlogPostListScroll from './components/BlogPostListScroll' import BlogPostListPage from './components/BlogPostListPage' +import { useRouter } from 'next/router' export const LayoutSearch = (props) => { const { locale } = useGlobal() const { keyword } = props + const router = useRouter() + const currentSearch = keyword || router?.query?.s + useEffect(() => { setTimeout(() => { const container = isBrowser() && document.getElementById('container') if (container && container.innerHTML) { - const re = new RegExp(keyword, 'gim') + const re = new RegExp(currentSearch, 'gim') const instance = new Mark(container) instance.markRegExp(re, { element: 'span', @@ -28,14 +32,20 @@ export const LayoutSearch = (props) => { 100) }) return +
{locale.NAV.SEARCH}
- - + + + {!currentSearch && <> + + } +
-
+ + {currentSearch &&
{BLOG.POST_LIST_STYLE === 'page' ? : } -
+
}
} diff --git a/themes/medium/LayoutSlug.js b/themes/medium/LayoutSlug.js index e0c52b84..f7fdc4d0 100644 --- a/themes/medium/LayoutSlug.js +++ b/themes/medium/LayoutSlug.js @@ -12,9 +12,7 @@ export const LayoutSlug = props => { const { locale } = useGlobal() if (!post) { - return } @@ -30,15 +28,8 @@ export const LayoutSlug = props => { ) return ( - - - {!lock && } - - {lock && } + + {!lock ? : } ) } diff --git a/themes/medium/components/ArticleDetail.js b/themes/medium/components/ArticleDetail.js index 5e6c4da5..ea129207 100644 --- a/themes/medium/components/ArticleDetail.js +++ b/themes/medium/components/ArticleDetail.js @@ -21,25 +21,24 @@ export const ArticleDetail = props => { return
{/* title */} -

{post?.title}

+

{post?.title}

{/* meta */} -
-
- {date} - | - {post.lastEditedTime} -
- - +
+
+ {date} + | + {post.lastEditedTime} +
+
{/* eslint-disable-next-line @next/next/no-img-element */} - + -
+
{BLOG.AUTHOR}