From 5fcf9189d04829935cf87ca4f2d9219c0cacd8d9 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 11 Jan 2022 16:27:58 +0800 Subject: [PATCH] toc\blogCard\searchInput.focus --- components/BlogPostCard.js | 11 ++++++----- components/SearchInput.js | 4 ++-- pages/article/[slug].js | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/BlogPostCard.js b/components/BlogPostCard.js index 6811ff93..785dcd18 100644 --- a/components/BlogPostCard.js +++ b/components/BlogPostCard.js @@ -10,18 +10,19 @@ import { useGlobal } from '@/lib/global' const BlogPostCard = ({ post, showSummary }) => { const { locale } = useGlobal() + const showPreview = BLOG.home?.showPreview && post.blockMap return (
-
+
- + {post.title} -
+ - {showSummary &&

+ {(!showPreview || showSummary) &&

{post.summary}

} - {BLOG.home?.showPreview && post?.blockMap &&
+ {showPreview && post?.blockMap &&
{ const { locale } = useGlobal() - const [searchKey, setSearchKey] = useState(currentSearch) + const [searchKey, setSearchKey] = useState(currentSearch || '') const [onLoading, setLoadingState] = useState(false) const router = useRouter() const searchInputRef = useRef() @@ -52,7 +52,7 @@ const SearchInput = ({ currentTag, currentSearch, cRef }) => { className={'w-full text-sm pl-2 transition focus:shadow-lg font-light leading-10 border-gray-300 text-black bg-gray-100 dark:bg-gray-900 dark:text-white'} onKeyUp={handleKeyUp} onChange={e => updateSearchKey(e.target.value)} - defaultValue={currentSearch} + defaultValue={searchKey} /> {(searchKey && searchKey.length && )} diff --git a/pages/article/[slug].js b/pages/article/[slug].js index ba0949f3..50fbf3f1 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -37,7 +37,7 @@ const Slug = ({ const drawerRight = useRef(null) const targetRef = typeof window !== 'undefined' ? document.getElementById('container') : null - const floatSlot =
{ drawerRight?.current?.handleSwitchVisible() }} />
+ const floatSlot = post?.toc.length > 1 ?
{ drawerRight?.current?.handleSwitchVisible() }} />
: null return (