meta移动端适配

This commit is contained in:
tangly1024
2022-12-07 18:59:19 +08:00
parent 900dc5fbd0
commit 47d2dcaa45
5 changed files with 163 additions and 166 deletions

View File

@@ -9,6 +9,8 @@ import { ArticleLock } from './components/ArticleLock'
export const LayoutSlug = props => { export const LayoutSlug = props => {
const { post, lock, validPassword } = props const { post, lock, validPassword } = props
const { locale } = useGlobal()
if (!post) { if (!post) {
return <LayoutBase return <LayoutBase
{...props} {...props}
@@ -20,7 +22,6 @@ export const LayoutSlug = props => {
post.content = Object.keys(post.blockMap.block) post.content = Object.keys(post.blockMap.block)
post.toc = getPageTableOfContents(post, post.blockMap) post.toc = getPageTableOfContents(post, post.blockMap)
} }
const { locale } = useGlobal()
const slotRight = post?.toc && post?.toc?.length > 3 && ( const slotRight = post?.toc && post?.toc?.length > 3 && (
<div key={locale.COMMON.TABLE_OF_CONTENTS} > <div key={locale.COMMON.TABLE_OF_CONTENTS} >

View File

@@ -19,28 +19,31 @@ export const ArticleDetail = props => {
locale.LOCALE locale.LOCALE
) )
return <div id='container'> return <div id='container'>
<h1 className="text-4xl pt-12 font-sans dark:text-gray-100">{post?.title}</h1>
<section className="flex py-4 items-center font-sans px-1">
<Link href="/about" passHref>
<>
{/* title */}
<h1 className="text-4xl pt-12 font-sans dark:text-gray-100">{post?.title}</h1>
{/* meta */}
<section className="py-2 items-center font-sans px-1">
<div className='flex text-gray-500 py-1 dark:text-gray-600'>
<span> <i className='far fa-calendar mr-2' />{date}</span>
<span className='mx-2'>|</span>
<span> <i className='far fa-calendar-check mr-2'/>{post.lastEditedTime}</span>
<div className="hidden busuanzi_container_page_pv font-light mr-2">
<i className="ml-3 mr-1 fas fa-eye" />
<span className="busuanzi_value_page_pv" />
</div>
</div>
<Link href="/about" passHref>
<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={25} />
<div className="mr-3 ml-1 text-green-500 cursor-pointer"> <div className="mr-3 ml-2 text-md text-green-500 cursor-pointer">
{BLOG.AUTHOR} {BLOG.AUTHOR}
</div> </div>
</> </div>
</Link> </Link>
<div className="text-gray-500">{date}</div>
<div className='mx-2 text-gray-300 dark:text-gray-600'>
{locale.COMMON.LAST_EDITED_TIME}: {post.lastEditedTime}
</div>
<div className="hidden busuanzi_container_page_pv text-gray-500 font-light mr-2">
<i className="ml-3 mr-0.5 fas fa-eye" />
&nbsp;
<span className="mr-2 busuanzi_value_page_pv" />
</div>
</section> </section>
{/* Notion文章主体 */} {/* Notion文章主体 */}
<section id="notion-article" className="px-1 max-w-5xl"> <section id="notion-article" className="px-1 max-w-5xl">

View File

@@ -12,15 +12,6 @@ import { isBrowser } from '@/lib/utils'
export const LayoutSlug = (props) => { export const LayoutSlug = (props) => {
const { post, latestPosts, lock, validPassword } = props const { post, latestPosts, lock, validPassword } = props
if (!post) {
return <LayoutBase
{...props}
rightAreaSlot={
CONFIG_NEXT.RIGHT_LATEST_POSTS && <Card><LatestPostsGroup posts={latestPosts} /></Card>
}
/>
}
if (!lock && post?.blockMap?.block) { if (!lock && post?.blockMap?.block) {
post.content = Object.keys(post.blockMap.block) post.content = Object.keys(post.blockMap.block)
post.toc = getPageTableOfContents(post, post.blockMap) post.toc = getPageTableOfContents(post, post.blockMap)
@@ -34,6 +25,15 @@ export const LayoutSlug = (props) => {
}} /></div> }} /></div>
: null : null
if (!post) {
return <LayoutBase
{...props}
rightAreaSlot={
CONFIG_NEXT.RIGHT_LATEST_POSTS && <Card><LatestPostsGroup posts={latestPosts} /></Card>
}
/>
}
return ( return (
<LayoutBase <LayoutBase
{...props} {...props}

View File

@@ -31,6 +31,7 @@ export default function ArticleDetail(props) {
> >
{showArticleInfo && <header className='animate__slideInDown animate__animated'> {showArticleInfo && <header className='animate__slideInDown animate__animated'>
{/* 头图 */}
{CONFIG_NEXT.POST_HEADER_IMAGE_VISIBLE && post?.type && !post?.type !== 'Page' && post?.page_cover && ( {CONFIG_NEXT.POST_HEADER_IMAGE_VISIBLE && post?.type && !post?.type !== 'Page' && post?.page_cover && (
<div className="w-full relative md:flex-shrink-0 overflow-hidden"> <div className="w-full relative md:flex-shrink-0 overflow-hidden">
{/* eslint-disable-next-line @next/next/no-img-element */} {/* eslint-disable-next-line @next/next/no-img-element */}
@@ -38,48 +39,31 @@ export default function ArticleDetail(props) {
</div> </div>
)} )}
{/* 文章Title */} {/* title */}
<div className="font-bold text-3xl text-black dark:text-white font-serif pt-10"> <div className=" text-center font-bold text-3xl text-black dark:text-white font-serif pt-6">
<NotionIcon icon={post.pageIcon} />{post.title} <NotionIcon icon={post.pageIcon} />{post.title}
</div> </div>
<section className="flex-wrap flex mt-2 text-gray-400 dark:text-gray-400 font-light leading-8"> {/* meta */}
<div className='flex flex-wrap'> <section className="mt-2 text-gray-400 dark:text-gray-400 font-light leading-7 text-sm">
{post.category && <> <div className='flex flex-wrap justify-center'>
<Link href={`/category/${post.category}`} passHref>
<a className="cursor-pointer text-md mr-2 hover:text-black dark:hover:text-white border-b dark:border-gray-500 border-dashed">
<i className="mr-1 far fa-folder-open" /> {post.category}
</a>
</Link>
<span className='mr-2'>|</span>
</>}
{post?.type !== 'Page' && (<> {post?.type !== 'Page' && (<>
<Link <Link href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} passHref>
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`} <div className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed">
passHref <i className='far fa-calendar mr-1' /> {date}
> </div>
<a className="pl-1 mr-2 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 border-b dark:border-gray-500 border-dashed">
{date}
</a>
</Link> </Link>
<span className='mr-2'>|</span> <span className='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">
<i className='mr-1 fas fa-eye' /> <i className='mr-1 fas fa-eye' />
&nbsp;
<span className="mr-2 busuanzi_value_page_pv" /> <span className="mr-2 busuanzi_value_page_pv" />
</div> </div>
</>)} </>)}
</div> </div>
<div className='mr-2'>
<i className='far fa-clock mr-2' />{locale.COMMON.LAST_EDITED_TIME} {post.lastEditedTime}
</div>
<div className='flex flex-nowrap whitespace-nowrap items-center font-light text-md'>
<WordCount /> <WordCount />
</div>
</section> </section>
</header>} </header>}
@@ -107,9 +91,20 @@ export default function ArticleDetail(props) {
{/* 推荐文章 */} {/* 推荐文章 */}
{post.type === 'Post' && <RecommendPosts currentPost={post} recommendPosts={recommendPosts} />} {post.type === 'Post' && <RecommendPosts currentPost={post} recommendPosts={recommendPosts} />}
<section className="flex justify-between">
{/* 分类 */}
{post.category && <>
<div className="cursor-pointer my-auto text-md mr-2 hover:text-black dark:hover:text-white border-b dark:border-gray-500 border-dashed">
<Link href={`/category/${post.category}`} passHref>
<><i className="mr-1 far fa-folder-open" /> {post.category}</>
</Link>
</div>
</>}
{/* 标签列表 */} {/* 标签列表 */}
{post.type === 'Post' && ( {post.type === 'Post' && (
<section className="md:flex md:justify-between"> <>
{post.tagItems && ( {post.tagItems && (
<div className="flex flex-nowrap leading-8 p-1 py-4 overflow-x-auto"> <div className="flex flex-nowrap leading-8 p-1 py-4 overflow-x-auto">
<div className="hidden md:block dark:text-gray-300 whitespace-nowrap"> <div className="hidden md:block dark:text-gray-300 whitespace-nowrap">
@@ -120,12 +115,10 @@ export default function ArticleDetail(props) {
))} ))}
</div> </div>
)} )}
<div>
<ShareBar post={post} /> <ShareBar post={post} />
</div> </>
</section>
)} )}
</section>
{post.type === 'Post' && <BlogAround prev={prev} next={next} />} {post.type === 'Post' && <BlogAround prev={prev} next={next} />}
</>} </>}

View File

@@ -9,8 +9,8 @@ export default function WordCount() {
countWords() countWords()
}) })
return <div id='wordCountWrapper' className='hidden'> return <div id='wordCountWrapper' className='flex justify-center my-auto font-light'>
<i className='mr-1 fas fa-file-word' /> 本文字数 <strong id='wordCount'>0</strong> &nbsp;|&nbsp; <i className='mr-1 fas fa-clock' /> 阅读时长 <strong id='readTime'>0</strong> <i className='mr-1 fas fa-file-word my-auto' /> <span className='hidden md:block'>本文字数</span> <strong id='wordCount'>0</strong> &nbsp;|&nbsp; <i className='mr-1 fas fa-clock my-auto' /> <span className='hidden md:block'> </span> <strong id='readTime'>0</strong>
</div> </div>
} }