mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-28 15:10:04 +00:00
@@ -9,15 +9,19 @@ import BLOG from '@/blog.config'
|
|||||||
import Mark from 'mark.js'
|
import Mark from 'mark.js'
|
||||||
import BlogPostListScroll from './components/BlogPostListScroll'
|
import BlogPostListScroll from './components/BlogPostListScroll'
|
||||||
import BlogPostListPage from './components/BlogPostListPage'
|
import BlogPostListPage from './components/BlogPostListPage'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
export const LayoutSearch = (props) => {
|
export const LayoutSearch = (props) => {
|
||||||
const { locale } = useGlobal()
|
const { locale } = useGlobal()
|
||||||
const { keyword } = props
|
const { keyword } = props
|
||||||
|
const router = useRouter()
|
||||||
|
const currentSearch = keyword || router?.query?.s
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const container = isBrowser() && document.getElementById('container')
|
const container = isBrowser() && document.getElementById('container')
|
||||||
if (container && container.innerHTML) {
|
if (container && container.innerHTML) {
|
||||||
const re = new RegExp(keyword, 'gim')
|
const re = new RegExp(currentSearch, 'gim')
|
||||||
const instance = new Mark(container)
|
const instance = new Mark(container)
|
||||||
instance.markRegExp(re, {
|
instance.markRegExp(re, {
|
||||||
element: 'span',
|
element: 'span',
|
||||||
@@ -28,14 +32,20 @@ export const LayoutSearch = (props) => {
|
|||||||
100)
|
100)
|
||||||
})
|
})
|
||||||
return <LayoutBase {...props}>
|
return <LayoutBase {...props}>
|
||||||
|
|
||||||
<div className='py-12'>
|
<div className='py-12'>
|
||||||
<div className='pb-4 w-full'>{locale.NAV.SEARCH}</div>
|
<div className='pb-4 w-full'>{locale.NAV.SEARCH}</div>
|
||||||
<SearchInput currentSearch={keyword} {...props} />
|
<SearchInput currentSearch={currentSearch} {...props} />
|
||||||
<TagGroups {...props} />
|
|
||||||
|
{!currentSearch && <>
|
||||||
|
<TagGroups {...props} />
|
||||||
<CategoryGroup {...props} />
|
<CategoryGroup {...props} />
|
||||||
|
</>}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
|
{currentSearch && <div>
|
||||||
{BLOG.POST_LIST_STYLE === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />}
|
{BLOG.POST_LIST_STYLE === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />}
|
||||||
</div>
|
</div>}
|
||||||
</LayoutBase>
|
</LayoutBase>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ export const LayoutSlug = props => {
|
|||||||
const { locale } = useGlobal()
|
const { locale } = useGlobal()
|
||||||
|
|
||||||
if (!post) {
|
if (!post) {
|
||||||
return <LayoutBase
|
return <LayoutBase {...props} showInfoCard={true}
|
||||||
{...props}
|
|
||||||
showInfoCard={true}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,15 +28,8 @@ export const LayoutSlug = props => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LayoutBase
|
<LayoutBase showInfoCard={true} slotRight={slotRight} {...props} >
|
||||||
{...props}
|
{!lock ? <ArticleDetail {...props} /> : <ArticleLock password={post.password} validPassword={validPassword} />}
|
||||||
showInfoCard={true}
|
|
||||||
slotRight={slotRight}
|
|
||||||
>
|
|
||||||
|
|
||||||
{!lock && <ArticleDetail {...props} />}
|
|
||||||
|
|
||||||
{lock && <ArticleLock password={post.password} validPassword={validPassword} />}
|
|
||||||
</LayoutBase>
|
</LayoutBase>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,25 +21,24 @@ export const ArticleDetail = props => {
|
|||||||
return <div id='container'>
|
return <div id='container'>
|
||||||
|
|
||||||
{/* title */}
|
{/* title */}
|
||||||
<h1 className="text-4xl pt-12 font-sans dark:text-gray-100">{post?.title}</h1>
|
<h1 className="text-3xl pt-12 font-sans dark:text-gray-100">{post?.title}</h1>
|
||||||
|
|
||||||
{/* meta */}
|
{/* meta */}
|
||||||
<section className="py-2 items-center font-sans px-1">
|
<section className="py-2 items-center text-sm font-sans px-1">
|
||||||
<div className='flex text-gray-500 py-1 dark:text-gray-600'>
|
<div className='flex flex-wrap text-gray-500 py-1 dark:text-gray-600'>
|
||||||
<span> <i className='far fa-calendar mr-2' />{date}</span>
|
<span className='whitespace-nowrap'> <i className='far fa-calendar mr-2' />{date}</span>
|
||||||
<span className='mx-2'>|</span>
|
<span className='mx-1'>|</span>
|
||||||
<span> <i className='far fa-calendar-check mr-2'/>{post.lastEditedTime}</span>
|
<span className='whitespace-nowrap mr-2'><i className='far fa-calendar-check mr-2'/>{post.lastEditedTime}</span>
|
||||||
<div className="hidden busuanzi_container_page_pv font-light mr-2">
|
<div className="hidden busuanzi_container_page_pv font-light mr-2 whitespace-nowrap">
|
||||||
<i className="ml-3 mr-1 fas fa-eye" />
|
<i className="mr-1 fas fa-eye" /><span className="busuanzi_value_page_pv" />
|
||||||
<span className="busuanzi_value_page_pv" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Link href="/about" passHref>
|
<Link href="/about" passHref>
|
||||||
<div className='flex pt-2'>
|
<div className='flex pt-2'>
|
||||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<img src={siteInfo?.icon} className='rounded-full cursor-pointer' width={25} />
|
<img src={siteInfo?.icon} className='rounded-full cursor-pointer' width={22} />
|
||||||
|
|
||||||
<div className="mr-3 ml-2 text-md text-green-500 cursor-pointer">
|
<div className="mr-3 ml-2 my-auto text-green-500 cursor-pointer">
|
||||||
{BLOG.AUTHOR}
|
{BLOG.AUTHOR}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user