From 5b6b9248852895b56514050691c17455bd0ad772 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 29 Apr 2022 15:25:21 +0800 Subject: [PATCH] =?UTF-8?q?example=20=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/example/LayoutArchive.js | 2 +- themes/example/LayoutBase.js | 4 ++-- themes/example/LayoutCategoryIndex.js | 8 ++------ themes/example/LayoutSearch.js | 7 +++++-- themes/example/LayoutTagIndex.js | 2 +- themes/example/components/ArticleInfo.js | 7 +++---- themes/example/components/BlogList.js | 8 ++++++++ 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/themes/example/LayoutArchive.js b/themes/example/LayoutArchive.js index a7657b12..1b3d1e34 100644 --- a/themes/example/LayoutArchive.js +++ b/themes/example/LayoutArchive.js @@ -24,7 +24,7 @@ export const LayoutArchive = props => { }) return ( -
+
{Object.keys(archivePosts).map(archiveTitle => (
diff --git a/themes/example/LayoutBase.js b/themes/example/LayoutBase.js index 54985d89..1f357ad8 100644 --- a/themes/example/LayoutBase.js +++ b/themes/example/LayoutBase.js @@ -28,9 +28,9 @@ const LayoutBase = props => { - <div className="container max-w-3xl mx-auto justify-center md:flex items-start py-8 px-2 md:px-4"> + <div className="container mx-auto justify-center md:flex items-start py-8 px-2"> - <div className='w-full'>{children}</div> + <div className='w-full max-w-3xl xl:px-14 lg:px-4 '>{children}</div> <SideBar {...props} /> diff --git a/themes/example/LayoutCategoryIndex.js b/themes/example/LayoutCategoryIndex.js index 77a3fcc1..7690b316 100644 --- a/themes/example/LayoutCategoryIndex.js +++ b/themes/example/LayoutCategoryIndex.js @@ -1,15 +1,11 @@ -import { useGlobal } from '@/lib/global' import Link from 'next/link' import LayoutBase from './LayoutBase' export const LayoutCategoryIndex = (props) => { const { categories } = props - const { locale } = useGlobal() + return <LayoutBase {...props}> - <div className=' p-10 w-full'> - <div className='dark:text-gray-200 mb-5'> - <i className='mr-4 fas fa-th' />{locale.COMMON.CATEGORY}: - </div> + <div > <div id='category-list' className='duration-200 flex flex-wrap'> {categories && categories.map(category => { return <Link key={category.name} href={`/category/${category.name}`} passHref> diff --git a/themes/example/LayoutSearch.js b/themes/example/LayoutSearch.js index 528c7976..c79c3ed0 100644 --- a/themes/example/LayoutSearch.js +++ b/themes/example/LayoutSearch.js @@ -1,12 +1,15 @@ import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import Link from 'next/link' +import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import SearchInput from './components/SearchInput' import LayoutBase from './LayoutBase' export const LayoutSearch = props => { const { keyword, posts } = props + const router = useRouter() + useEffect(() => { setTimeout(() => { const container = typeof document !== 'undefined' && document.getElementById('container') @@ -15,7 +18,7 @@ export const LayoutSearch = props => { container.innerHTML = container.innerHTML.replace(re, `<span class='text-red-500 border-b border-dashed'>${keyword}</span>`) } }, 100) - }) + }, [router.events]) const { locale } = useGlobal() @@ -51,7 +54,7 @@ export const LayoutSearch = props => { }, []) return <LayoutBase {...props}> - <div className='py-2'> + <div className='pb-12'> <SearchInput {...props} /> </div> diff --git a/themes/example/LayoutTagIndex.js b/themes/example/LayoutTagIndex.js index 249e1639..6a89e168 100644 --- a/themes/example/LayoutTagIndex.js +++ b/themes/example/LayoutTagIndex.js @@ -4,7 +4,7 @@ import LayoutBase from './LayoutBase' export const LayoutTagIndex = (props) => { const { tags } = props return <LayoutBase {...props}> - <div className='p-10'> + <div> <div id='tags-list' className='duration-200 flex flex-wrap'> {tags.map(tag => { return <div key={tag.name} className='p-2'> diff --git a/themes/example/components/ArticleInfo.js b/themes/example/components/ArticleInfo.js index 7e92e254..f7dc5a80 100644 --- a/themes/example/components/ArticleInfo.js +++ b/themes/example/components/ArticleInfo.js @@ -34,14 +34,13 @@ export const ArticleInfo = (props) => { {locale.COMMON.LAST_EDITED_TIME}: {post.lastEditedTime} </span> <span className='mr-2'>|</span> - - </>)} - - <span className="hidden busuanzi_container_page_pv font-light mr-2"> + <span className="hidden busuanzi_container_page_pv font-light mr-2"> <i className='mr-1 fas fa-eye' />   <span className="mr-2 busuanzi_value_page_pv" /> </span> + </>)} + </div> </section> diff --git a/themes/example/components/BlogList.js b/themes/example/components/BlogList.js index bb924fdf..7e2b49f0 100644 --- a/themes/example/components/BlogList.js +++ b/themes/example/components/BlogList.js @@ -39,6 +39,14 @@ export const BlogList = (props) => { <p className="text-gray-700 leading-normal"> {p.summary} </p> + {/* 搜索结果 */} + {p.results && ( + <p className="mt-4 text-gray-700 dark:text-gray-300 text-sm font-light leading-7"> + {p.results.map(r => ( + <span key={r}>{r}</span> + ))} + </p> + )} </article> ))}