mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
magzine主题雏形
This commit is contained in:
27
themes/magzine/components/Announcement.js
Normal file
27
themes/magzine/components/Announcement.js
Normal file
@@ -0,0 +1,27 @@
|
||||
// import { useGlobal } from '@/lib/global'
|
||||
import dynamic from 'next/dynamic'
|
||||
|
||||
const NotionPage = dynamic(() => import('@/components/NotionPage'))
|
||||
|
||||
const Announcement = ({ post, className }) => {
|
||||
// const { locale } = useGlobal()
|
||||
if (post?.blockMap) {
|
||||
return (
|
||||
<div className={className}>
|
||||
<section
|
||||
id='announcement-wrapper'
|
||||
className='dark:text-gray-300 rounded-xl px-2 py-4'>
|
||||
{/* <div><i className='mr-2 fas fa-bullhorn' />{locale.COMMON.ANNOUNCEMENT}</div> */}
|
||||
{post && (
|
||||
<div id='announcement-content'>
|
||||
<NotionPage post={post} className='' />
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return <></>
|
||||
}
|
||||
}
|
||||
export default Announcement
|
||||
32
themes/magzine/components/ArticleAround.js
Normal file
32
themes/magzine/components/ArticleAround.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import Link from 'next/link'
|
||||
|
||||
/**
|
||||
* 上一篇,下一篇文章
|
||||
* @param {prev,next} param0
|
||||
* @returns
|
||||
*/
|
||||
export default function ArticleAround ({ prev, next }) {
|
||||
if (!prev || !next) {
|
||||
return <></>
|
||||
}
|
||||
return (
|
||||
<section className='text-gray-800 dark:text-gray-400 h-12 flex items-center justify-between space-x-5 my-4'>
|
||||
<Link
|
||||
href={`/${prev.slug}`}
|
||||
passHref
|
||||
className='text-sm cursor-pointer justify-start items-center flex hover:underline duration-300'>
|
||||
|
||||
<i className='mr-1 fas fa-angle-double-left' />{prev.title}
|
||||
|
||||
</Link>
|
||||
<Link
|
||||
href={`/${next.slug}`}
|
||||
passHref
|
||||
className='text-sm cursor-pointer justify-end items-center flex hover:underline duration-300'>
|
||||
{next.title}
|
||||
<i className='ml-1 my-1 fas fa-angle-double-right' />
|
||||
|
||||
</Link>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
57
themes/magzine/components/ArticleInfo.js
Normal file
57
themes/magzine/components/ArticleInfo.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import LazyImage from '@/components/LazyImage'
|
||||
import NotionIcon from '@/components/NotionIcon'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import Link from 'next/link'
|
||||
|
||||
/**
|
||||
* 文章详情页介绍
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
export default function ArticleInfo(props) {
|
||||
const { post, siteInfo } = props
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* title */}
|
||||
<h1 className='text-3xl pt-12 dark:text-gray-300'>
|
||||
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post?.pageIcon} />}
|
||||
{post?.title}
|
||||
</h1>
|
||||
|
||||
{/* meta */}
|
||||
<section className='py-2 items-center text-sm px-1'>
|
||||
<div className='flex flex-wrap text-gray-500 py-1 dark:text-gray-600'>
|
||||
<span className='whitespace-nowrap'>
|
||||
{' '}
|
||||
<i className='far fa-calendar mr-2' />
|
||||
{post?.publishDay}
|
||||
</span>
|
||||
<span className='mx-1'>|</span>
|
||||
<span className='whitespace-nowrap mr-2'>
|
||||
<i className='far fa-calendar-check mr-2' />
|
||||
{post?.lastEditedDay}
|
||||
</span>
|
||||
<div className='hidden busuanzi_container_page_pv font-light mr-2 whitespace-nowrap'>
|
||||
<i className='mr-1 fas fa-eye' />
|
||||
<span className='busuanzi_value_page_pv' />
|
||||
</div>
|
||||
</div>
|
||||
<Link href='/about' passHref legacyBehavior>
|
||||
<div className='flex pt-2'>
|
||||
<LazyImage
|
||||
src={siteInfo?.icon}
|
||||
className='rounded-full cursor-pointer'
|
||||
width={22}
|
||||
alt={siteConfig('AUTHOR')}
|
||||
/>
|
||||
|
||||
<div className='mr-3 ml-2 my-auto text-gray-500 cursor-pointer'>
|
||||
{siteConfig('AUTHOR')}
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
</section>
|
||||
</>
|
||||
)
|
||||
}
|
||||
61
themes/magzine/components/ArticleLock.js
Normal file
61
themes/magzine/components/ArticleLock.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { useEffect, useRef } from 'react'
|
||||
|
||||
/**
|
||||
* 加密文章校验组件
|
||||
* @param {password, validPassword} props
|
||||
* @param password 正确的密码
|
||||
* @param validPassword(bool) 回调函数,校验正确回调入参为true
|
||||
* @returns
|
||||
*/
|
||||
export const ArticleLock = props => {
|
||||
const { validPassword } = props
|
||||
const { locale } = useGlobal()
|
||||
|
||||
const submitPassword = () => {
|
||||
const p = document.getElementById('password')
|
||||
if (!validPassword(p?.value)) {
|
||||
const tips = document.getElementById('tips')
|
||||
if (tips) {
|
||||
tips.innerHTML = ''
|
||||
tips.innerHTML = `<div class='text-red-500 animate__shakeX animate__animated'>${locale.COMMON.PASSWORD_ERROR}</div>`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const passwordInputRef = useRef(null)
|
||||
useEffect(() => {
|
||||
// 选中密码输入框并将其聚焦
|
||||
passwordInputRef.current.focus()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div
|
||||
id='container'
|
||||
className='w-full flex justify-center items-center h-96 '>
|
||||
<div className='text-center space-y-3'>
|
||||
<div className='font-bold'>{locale.COMMON.ARTICLE_LOCK_TIPS}</div>
|
||||
<div className='flex mx-4'>
|
||||
<input
|
||||
id='password'
|
||||
type='password'
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'Enter') {
|
||||
submitPassword()
|
||||
}
|
||||
}}
|
||||
ref={passwordInputRef} // 绑定ref到passwordInputRef变量
|
||||
className='outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg dark:text-gray-300 font-light leading-10 text-black bg-gray-100 dark:bg-gray-500'></input>
|
||||
<div
|
||||
onClick={submitPassword}
|
||||
className='px-3 whitespace-nowrap cursor-pointer items-center justify-center py-2 bg-gray-500 hover:bg-gray-400 text-white rounded-r duration-300'>
|
||||
<i className={'duration-200 cursor-pointer fas fa-key'}>
|
||||
{locale.COMMON.SUBMIT}
|
||||
</i>
|
||||
</div>
|
||||
</div>
|
||||
<div id='tips'></div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
36
themes/magzine/components/BlogArchiveItem.js
Normal file
36
themes/magzine/components/BlogArchiveItem.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import Link from 'next/link'
|
||||
|
||||
/**
|
||||
* 归档分组
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
|
||||
return (
|
||||
<div key={archiveTitle}>
|
||||
<div id={archiveTitle} className='pt-16 pb-4 text-3xl dark:text-gray-300'>
|
||||
{archiveTitle}
|
||||
</div>
|
||||
<ul>
|
||||
{archivePosts[archiveTitle]?.map(post => {
|
||||
return (
|
||||
<li
|
||||
key={post.id}
|
||||
className='border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500'>
|
||||
<div id={post?.publishDay}>
|
||||
<span className='text-gray-400'>{post.date?.start_date}</span>{' '}
|
||||
|
||||
<Link
|
||||
passHref
|
||||
href={post?.href}
|
||||
className='dark:text-gray-400 dark:hover:text-gray-300 overflow-x-hidden hover:underline cursor-pointer text-gray-600'>
|
||||
{post.title}
|
||||
</Link>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
29
themes/magzine/components/BlogPostBar.js
Normal file
29
themes/magzine/components/BlogPostBar.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
/**
|
||||
* 文章列表上方嵌入
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
export default function BlogPostBar(props) {
|
||||
const { tag, category } = props
|
||||
const { locale } = useGlobal()
|
||||
|
||||
if (tag) {
|
||||
return (
|
||||
<div className='flex items-center text-xl py-8'>
|
||||
<i className='mr-2 fas fa-tag' />
|
||||
{locale.COMMON.TAGS}:{tag}
|
||||
</div>
|
||||
)
|
||||
} else if (category) {
|
||||
return (
|
||||
<div className='flex items-center text-xl py-8'>
|
||||
<i className='mr-2 fas fa-th' />
|
||||
{locale.COMMON.CATEGORY}:{category}
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return <></>
|
||||
}
|
||||
}
|
||||
92
themes/magzine/components/BlogPostCard.js
Normal file
92
themes/magzine/components/BlogPostCard.js
Normal file
@@ -0,0 +1,92 @@
|
||||
import LazyImage from '@/components/LazyImage'
|
||||
import NotionIcon from '@/components/NotionIcon'
|
||||
import NotionPage from '@/components/NotionPage'
|
||||
import TwikooCommentCount from '@/components/TwikooCommentCount'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import Link from 'next/link'
|
||||
import CONFIG from '../config'
|
||||
import CategoryItem from './CategoryItem'
|
||||
import TagItemMini from './TagItemMini'
|
||||
|
||||
const BlogPostCard = ({ post, showSummary }) => {
|
||||
const showPreview =
|
||||
siteConfig('MEDIUM_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
|
||||
const { locale } = useGlobal()
|
||||
return (
|
||||
<div
|
||||
key={post.id}
|
||||
data-aos='fade-up'
|
||||
data-aos-duration='300'
|
||||
data-aos-once='false'
|
||||
data-aos-anchor-placement='top-bottom'
|
||||
className='mb-6 max-w-7xl border-b dark:border-gray-800 '>
|
||||
<header className='lg:py-8 py-4 flex flex-col w-full'>
|
||||
<Link
|
||||
href={post?.href}
|
||||
passHref
|
||||
className={
|
||||
'cursor-pointer font-bold hover:underline text-3xl leading-tight text-gray-700 dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-400'
|
||||
}>
|
||||
<h2>
|
||||
{siteConfig('MEDIUM_POST_LIST_COVER', null, CONFIG) && (
|
||||
<div className='w-full max-h-96 object-cover overflow-hidden mb-2'>
|
||||
<LazyImage
|
||||
src={post.pageCoverThumbnail}
|
||||
style={post.pageCoverThumbnail ? {} : { height: '0px' }}
|
||||
className='w-full max-h-96 object-cover hover:scale-125 duration-150'
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{siteConfig('POST_TITLE_ICON') && (
|
||||
<NotionIcon icon={post.pageIcon} />
|
||||
)}
|
||||
{post.title}
|
||||
</h2>
|
||||
</Link>
|
||||
|
||||
<div
|
||||
className={
|
||||
'flex mt-2 items-center justify-start flex-wrap space-x-3 text-gray-400'
|
||||
}>
|
||||
<div className='text-sm py-1'>{post.date?.start_date}</div>
|
||||
{siteConfig('MEDIUM_POST_LIST_CATEGORY', null, CONFIG) && (
|
||||
<CategoryItem category={post.category} />
|
||||
)}
|
||||
{siteConfig('MEDIUM_POST_LIST_TAG', null, CONFIG) &&
|
||||
post?.tagItems?.map(tag => (
|
||||
<TagItemMini key={tag.name} tag={tag} />
|
||||
))}
|
||||
<TwikooCommentCount post={post} className='hover:underline' />
|
||||
</div>
|
||||
|
||||
<div className='flex'></div>
|
||||
|
||||
{(!showPreview || showSummary) && (
|
||||
<main className='my-4 text-gray-700 dark:text-gray-300 text-sm font-light leading-7'>
|
||||
{post.summary}
|
||||
</main>
|
||||
)}
|
||||
|
||||
{showPreview && (
|
||||
<div className='overflow-ellipsis truncate'>
|
||||
<NotionPage post={post} />
|
||||
<div className='pointer-events-none border-t pt-8 border-dashed'>
|
||||
<div className='w-full justify-start flex'>
|
||||
<Link
|
||||
href={post?.href}
|
||||
passHref
|
||||
className='hover:bg-opacity-100 hover:scale-105 duration-200 pointer-events-auto transform font-bold text-gray-500 cursor-pointer'>
|
||||
{locale.COMMON.ARTICLE_DETAIL}
|
||||
<i className='ml-1 fas fa-angle-right' />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BlogPostCard
|
||||
85
themes/magzine/components/BlogPostCardHorizontal.js
Normal file
85
themes/magzine/components/BlogPostCardHorizontal.js
Normal file
@@ -0,0 +1,85 @@
|
||||
import LazyImage from '@/components/LazyImage'
|
||||
import NotionIcon from '@/components/NotionIcon'
|
||||
import NotionPage from '@/components/NotionPage'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import Link from 'next/link'
|
||||
import CONFIG from '../config'
|
||||
import CategoryItem from './CategoryItem'
|
||||
import TagItemMini from './TagItemMini'
|
||||
|
||||
const BlogPostCardHorizontal = ({ post, showSummary }) => {
|
||||
const showPreview =
|
||||
siteConfig('MEDIUM_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
|
||||
const { locale } = useGlobal()
|
||||
return (
|
||||
<div
|
||||
key={post.id}
|
||||
className='flex justify-between space-x-6 mb-6 border-top border-gray-200'>
|
||||
{/* 卡牌左侧 */}
|
||||
<div className='h-40 w-96'>
|
||||
<Link
|
||||
href={post?.href}
|
||||
passHref
|
||||
className={
|
||||
' cursor-pointer font-bold hover:underline text-xl leading-tight text-gray-700 dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-400'
|
||||
}>
|
||||
<h3 className='max-w-80 break-words'>
|
||||
{siteConfig('POST_TITLE_ICON') && (
|
||||
<NotionIcon icon={post.pageIcon} />
|
||||
)}
|
||||
{post.title}
|
||||
</h3>
|
||||
</Link>
|
||||
|
||||
<div
|
||||
className={
|
||||
'flex mt-2 items-center justify-start flex-wrap space-x-3 text-gray-400'
|
||||
}>
|
||||
<div className='text-sm py-1'>{post.date?.start_date}</div>
|
||||
{siteConfig('MEDIUM_POST_LIST_CATEGORY', null, CONFIG) && (
|
||||
<CategoryItem category={post.category} />
|
||||
)}
|
||||
{siteConfig('MEDIUM_POST_LIST_TAG', null, CONFIG) &&
|
||||
post?.tagItems?.map(tag => (
|
||||
<TagItemMini key={tag.name} tag={tag} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
{(!showPreview || showSummary) && (
|
||||
<main className='my-4 line-clamp-2 text-gray-700 dark:text-gray-300 text-sm font-light leading-7'>
|
||||
{post.summary}
|
||||
</main>
|
||||
)}
|
||||
|
||||
{showPreview && (
|
||||
<div className='overflow-ellipsis truncate'>
|
||||
<NotionPage post={post} />
|
||||
<div className='pointer-events-none border-t pt-8 border-dashed'>
|
||||
<div className='w-full justify-start flex'>
|
||||
<Link
|
||||
href={post?.href}
|
||||
passHref
|
||||
className='hover:bg-opacity-100 hover:scale-105 duration-200 pointer-events-auto transform font-bold text-gray-500 cursor-pointer'>
|
||||
{locale.COMMON.ARTICLE_DETAIL}
|
||||
<i className='ml-1 fas fa-angle-right' />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 卡牌右侧图片 */}
|
||||
<div className='w-40 h-40 object-cover overflow-hidden mb-2'>
|
||||
<LazyImage
|
||||
src={post.pageCoverThumbnail}
|
||||
style={post.pageCoverThumbnail ? {} : { height: '0px' }}
|
||||
className='w-40 h-40 object-cover hover:scale-125 duration-150'
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BlogPostCardHorizontal
|
||||
106
themes/magzine/components/BlogPostCardTop.js
Normal file
106
themes/magzine/components/BlogPostCardTop.js
Normal file
@@ -0,0 +1,106 @@
|
||||
import LazyImage from '@/components/LazyImage'
|
||||
import NotionIcon from '@/components/NotionIcon'
|
||||
import NotionPage from '@/components/NotionPage'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import Link from 'next/link'
|
||||
import CONFIG from '../config'
|
||||
import CategoryItem from './CategoryItem'
|
||||
import TagItemMini from './TagItemMini'
|
||||
|
||||
/**
|
||||
* 置顶头条文章
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
const BlogPostCardTop = ({ post, showSummary }) => {
|
||||
const showPreview =
|
||||
siteConfig('MEDIUM_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
|
||||
const { locale } = useGlobal()
|
||||
return (
|
||||
<div
|
||||
key={post.id}
|
||||
data-aos='fade-up'
|
||||
data-aos-duration='300'
|
||||
data-aos-once='false'
|
||||
data-aos-anchor-placement='top-bottom'
|
||||
className='mb-6 max-w-7xl '>
|
||||
<div className='flex flex-col w-full'>
|
||||
{siteConfig('MEDIUM_POST_LIST_COVER', null, CONFIG) && (
|
||||
<Link
|
||||
href={post?.href}
|
||||
passHref
|
||||
className={
|
||||
'cursor-pointer hover:underline font-bold text-3xl leading-tight dark:text-gray-300 dark:hover:text-gray-400'
|
||||
}>
|
||||
<div className='w-full max-h-80 object-cover overflow-hidden mb-2'>
|
||||
<LazyImage
|
||||
src={post.pageCoverThumbnail}
|
||||
style={post.pageCoverThumbnail ? {} : { height: '0px' }}
|
||||
className='w-full max-h-80 object-cover hover:scale-125 duration-150'
|
||||
/>
|
||||
</div>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<div className='flex py-2 items-center'>
|
||||
{siteConfig('MEDIUM_POST_LIST_CATEGORY', null, CONFIG) && (
|
||||
<CategoryItem category={post.category} />
|
||||
)}
|
||||
<div
|
||||
className={
|
||||
'flex items-center justify-start flex-wrap space-x-3 text-gray-400'
|
||||
}>
|
||||
{siteConfig('MEDIUM_POST_LIST_TAG', null, CONFIG) &&
|
||||
post?.tagItems?.map(tag => (
|
||||
<TagItemMini key={tag.name} tag={tag} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Link
|
||||
href={post?.href}
|
||||
passHref
|
||||
className={
|
||||
'cursor-pointer hover:underline font-bold text-3xl leading-tight dark:text-gray-300 dark:hover:text-gray-400'
|
||||
}>
|
||||
<h2 className='text-2xl'>
|
||||
{siteConfig('POST_TITLE_ICON') && (
|
||||
<NotionIcon icon={post.pageIcon} />
|
||||
)}
|
||||
{post.title}
|
||||
</h2>
|
||||
</Link>
|
||||
|
||||
<div className='flex'></div>
|
||||
|
||||
{(!showPreview || showSummary) && (
|
||||
<main className='my-4 text-gray-700 dark:text-gray-300 text-sm font-light leading-7'>
|
||||
{post.summary}
|
||||
</main>
|
||||
)}
|
||||
|
||||
{showPreview && (
|
||||
<div className='overflow-ellipsis truncate'>
|
||||
<NotionPage post={post} />
|
||||
<div className='pointer-events-none border-t pt-8 border-dashed'>
|
||||
<div className='w-full justify-start flex'>
|
||||
<Link
|
||||
href={post?.href}
|
||||
passHref
|
||||
className='hover:bg-opacity-100 hover:scale-105 duration-200 pointer-events-auto transform font-bold text-gray-500 cursor-pointer'>
|
||||
{locale.COMMON.ARTICLE_DETAIL}
|
||||
<i className='ml-1 fas fa-angle-right' />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className='text-sm py-1'>{post.date?.start_date}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BlogPostCardTop
|
||||
14
themes/magzine/components/BlogPostListEmpty.js
Normal file
14
themes/magzine/components/BlogPostListEmpty.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
/**
|
||||
* 空白博客 列表
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const BlogPostListEmpty = ({ currentSearch }) => {
|
||||
const { locale } = useGlobal()
|
||||
return <div className='flex w-full items-center justify-center min-h-screen mx-auto md:-mt-20'>
|
||||
<p className='text-gray-500 dark:text-gray-300'>{locale.COMMON.NO_RESULTS_FOUND} {(currentSearch && <div>{currentSearch}</div>)}</p>
|
||||
</div>
|
||||
}
|
||||
export default BlogPostListEmpty
|
||||
37
themes/magzine/components/BlogPostListPage.js
Normal file
37
themes/magzine/components/BlogPostListPage.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import BlogPostCard from './BlogPostCard'
|
||||
import BlogPostListEmpty from './BlogPostListEmpty'
|
||||
import PaginationSimple from './PaginationSimple'
|
||||
|
||||
/**
|
||||
* 文章列表分页表格
|
||||
* @param page 当前页
|
||||
* @param posts 所有文章
|
||||
* @param tags 所有标签
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
|
||||
const { NOTION_CONFIG } = useGlobal()
|
||||
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
|
||||
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
|
||||
|
||||
if (!posts || posts.length === 0) {
|
||||
return <BlogPostListEmpty />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='w-full justify-center'>
|
||||
<div id='posts-wrapper'>
|
||||
{/* 文章列表 */}
|
||||
{posts?.map(post => (
|
||||
<BlogPostCard key={post.id} post={post} />
|
||||
))}
|
||||
</div>
|
||||
<PaginationSimple page={page} totalPage={totalPage} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BlogPostListPage
|
||||
107
themes/magzine/components/BlogPostListScroll.js
Normal file
107
themes/magzine/components/BlogPostListScroll.js
Normal file
@@ -0,0 +1,107 @@
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import throttle from 'lodash.throttle'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import BlogPostCard from './BlogPostCard'
|
||||
import BlogPostListEmpty from './BlogPostListEmpty'
|
||||
|
||||
/**
|
||||
* 博客列表滚动分页
|
||||
* @param posts 所有文章
|
||||
* @param tags 所有标签
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const BlogPostListScroll = ({ posts = [], currentSearch }) => {
|
||||
const { NOTION_CONFIG } = useGlobal()
|
||||
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
|
||||
const [page, updatePage] = useState(1)
|
||||
const router = useRouter()
|
||||
let filteredPosts = Object.assign(posts)
|
||||
const searchKey = router?.query?.s || null
|
||||
if (searchKey) {
|
||||
filteredPosts = posts.filter(post => {
|
||||
const tagContent = post?.tags ? post?.tags.join(' ') : ''
|
||||
const searchContent = post.title + post.summary + tagContent
|
||||
return searchContent.toLowerCase().includes(searchKey.toLowerCase())
|
||||
})
|
||||
}
|
||||
const postsToShow = getPostByPage(page, filteredPosts, POSTS_PER_PAGE)
|
||||
|
||||
let hasMore = false
|
||||
if (filteredPosts) {
|
||||
const totalCount = filteredPosts.length
|
||||
hasMore = page * POSTS_PER_PAGE < totalCount
|
||||
}
|
||||
|
||||
const handleGetMore = () => {
|
||||
if (!hasMore) return
|
||||
updatePage(page + 1)
|
||||
}
|
||||
|
||||
// 监听滚动自动分页加载
|
||||
const scrollTrigger = useCallback(
|
||||
throttle(() => {
|
||||
const scrollS = window.scrollY + window.outerHeight
|
||||
const clientHeight = targetRef
|
||||
? targetRef.current
|
||||
? targetRef.current.clientHeight
|
||||
: 0
|
||||
: 0
|
||||
if (scrollS > clientHeight + 100) {
|
||||
handleGetMore()
|
||||
}
|
||||
}, 500)
|
||||
)
|
||||
|
||||
// 监听滚动
|
||||
useEffect(() => {
|
||||
window.addEventListener('scroll', scrollTrigger)
|
||||
return () => {
|
||||
window.removeEventListener('scroll', scrollTrigger)
|
||||
}
|
||||
})
|
||||
|
||||
const targetRef = useRef(null)
|
||||
const { locale } = useGlobal()
|
||||
|
||||
if (!postsToShow || postsToShow.length === 0) {
|
||||
return <BlogPostListEmpty currentSearch={currentSearch} />
|
||||
} else {
|
||||
return (
|
||||
<div id='posts-wrapper' ref={targetRef} className='w-full'>
|
||||
{/* 文章列表 */}
|
||||
<div className='space-y-1 lg:space-y-4'>
|
||||
{postsToShow?.map(post => (
|
||||
<BlogPostCard key={post.id} post={post} showSummary={true} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div
|
||||
onClick={() => {
|
||||
handleGetMore()
|
||||
}}
|
||||
className='w-full my-4 py-4 text-center cursor-pointer dark:text-gray-200'>
|
||||
{' '}
|
||||
{hasMore ? locale.COMMON.MORE : `${locale.COMMON.NO_MORE} 😰`}{' '}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取从第1页到指定页码的文章
|
||||
* @param page 第几页
|
||||
* @param totalPosts 所有文章
|
||||
* @param POSTS_PER_PAGE 每页文章数量
|
||||
* @returns {*}
|
||||
*/
|
||||
const getPostByPage = function (page, totalPosts, POSTS_PER_PAGE) {
|
||||
return totalPosts.slice(0, POSTS_PER_PAGE * page)
|
||||
}
|
||||
|
||||
export default BlogPostListScroll
|
||||
9
themes/magzine/components/Card.js
Normal file
9
themes/magzine/components/Card.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const Card = ({ children, headerSlot, className }) => {
|
||||
return <div className={className}>
|
||||
<>{headerSlot}</>
|
||||
<section className="shadow px-2 py-4 bg-white dark:bg-gray-800 hover:shadow-xl duration-200">
|
||||
{children}
|
||||
</section>
|
||||
</div>
|
||||
}
|
||||
export default Card
|
||||
99
themes/magzine/components/Catalog.js
Normal file
99
themes/magzine/components/Catalog.js
Normal file
@@ -0,0 +1,99 @@
|
||||
import throttle from 'lodash.throttle'
|
||||
import { uuidToId } from 'notion-utils'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import Progress from './Progress'
|
||||
|
||||
/**
|
||||
* 目录导航组件
|
||||
* @param toc
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const Catalog = ({ toc }) => {
|
||||
const tocIds = []
|
||||
|
||||
// 目录自动滚动
|
||||
const tRef = useRef(null)
|
||||
// 同步选中目录事件
|
||||
const [activeSection, setActiveSection] = useState(null)
|
||||
|
||||
// 监听滚动事件
|
||||
useEffect(() => {
|
||||
window.addEventListener('scroll', actionSectionScrollSpy)
|
||||
actionSectionScrollSpy()
|
||||
return () => {
|
||||
window.removeEventListener('scroll', actionSectionScrollSpy)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const throttleMs = 200
|
||||
const actionSectionScrollSpy = useCallback(
|
||||
throttle(() => {
|
||||
const sections = document.getElementsByClassName('notion-h')
|
||||
let prevBBox = null
|
||||
let currentSectionId = activeSection
|
||||
for (let i = 0; i < sections.length; ++i) {
|
||||
const section = sections[i]
|
||||
if (!section || !(section instanceof Element)) continue
|
||||
if (!currentSectionId) {
|
||||
currentSectionId = section.getAttribute('data-id')
|
||||
}
|
||||
const bbox = section.getBoundingClientRect()
|
||||
const prevHeight = prevBBox ? bbox.top - prevBBox.bottom : 0
|
||||
const offset = Math.max(150, prevHeight / 4)
|
||||
// GetBoundingClientRect returns values relative to viewport
|
||||
if (bbox.top - offset < 0) {
|
||||
currentSectionId = section.getAttribute('data-id')
|
||||
prevBBox = bbox
|
||||
continue
|
||||
}
|
||||
// No need to continue loop, if last element has been detected
|
||||
break
|
||||
}
|
||||
setActiveSection(currentSectionId)
|
||||
const index = tocIds.indexOf(currentSectionId) || 0
|
||||
tRef?.current?.scrollTo({ top: 28 * index, behavior: 'smooth' })
|
||||
}, throttleMs)
|
||||
)
|
||||
|
||||
// 无目录就直接返回空
|
||||
if (!toc || toc.length < 1) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='px-3'>
|
||||
<div className='w-full mt-2 mb-4'>
|
||||
<Progress />
|
||||
</div>
|
||||
<div
|
||||
className='overflow-y-auto max-h-44 overscroll-none scroll-hidden'
|
||||
ref={tRef}>
|
||||
<nav className='h-full text-black'>
|
||||
{toc.map(tocItem => {
|
||||
const id = uuidToId(tocItem.id)
|
||||
tocIds.push(id)
|
||||
return (
|
||||
<a
|
||||
key={id}
|
||||
href={`#${id}`}
|
||||
className={`notion-table-of-contents-item duration-300 transform font-light dark:text-gray-300
|
||||
notion-table-of-contents-item-indent-level-${tocItem.indentLevel} `}>
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-block',
|
||||
marginLeft: tocItem.indentLevel * 16
|
||||
}}
|
||||
className={`truncate ${activeSection === id ? 'font-bold text-gray-500 underline' : ''}`}>
|
||||
{tocItem.text}
|
||||
</span>
|
||||
</a>
|
||||
)
|
||||
})}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Catalog
|
||||
37
themes/magzine/components/CategoryGroup.js
Normal file
37
themes/magzine/components/CategoryGroup.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import CategoryItem from './CategoryItem'
|
||||
|
||||
/**
|
||||
* 分类
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
const CategoryGroup = ({ currentCategory, categoryOptions }) => {
|
||||
const { locale } = useGlobal()
|
||||
if (!categoryOptions) {
|
||||
return <></>
|
||||
}
|
||||
return (
|
||||
<div id='category-list' className='pt-4'>
|
||||
<div className='mb-2'>
|
||||
<i className='mr-2 fas fa-th' />
|
||||
{locale.COMMON.CATEGORY}
|
||||
</div>
|
||||
<div className='flex flex-wrap'>
|
||||
{categoryOptions?.map(category => {
|
||||
const selected = currentCategory === category.name
|
||||
return (
|
||||
<CategoryItem
|
||||
key={category.name}
|
||||
selected={selected}
|
||||
category={category.name}
|
||||
categoryCount={category.count}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default CategoryGroup
|
||||
22
themes/magzine/components/CategoryItem.js
Normal file
22
themes/magzine/components/CategoryItem.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import Link from 'next/link'
|
||||
|
||||
export default function CategoryItem({ selected, category, categoryCount }) {
|
||||
return (
|
||||
<Link
|
||||
href={`/category/${category}`}
|
||||
passHref
|
||||
className={
|
||||
(selected
|
||||
? ' bg-gray-600 text-white '
|
||||
: 'dark:text-gray-400 text-gray-500 ') +
|
||||
' flex text-sm items-center duration-300 cursor-pointer py-1 font-light px-2 whitespace-nowrap'
|
||||
}>
|
||||
<div>
|
||||
<i
|
||||
className={`mr-2 fas ${selected ? 'fa-folder-open' : 'fa-folder'}`}
|
||||
/>
|
||||
{category} {categoryCount && `(${categoryCount})`}
|
||||
</div>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
30
themes/magzine/components/Footer.js
Normal file
30
themes/magzine/components/Footer.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import DarkModeButton from '@/components/DarkModeButton'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
|
||||
const Footer = ({ title }) => {
|
||||
const d = new Date()
|
||||
const currentYear = d.getFullYear()
|
||||
const since = siteConfig('SINCE')
|
||||
const copyrightDate = parseInt(since) < currentYear ? since + '-' + currentYear : currentYear
|
||||
|
||||
return (
|
||||
<footer
|
||||
className='z-10 dark:bg-hexo-black-gray flex-shrink-0 justify-center text-center m-auto w-full leading-6 text-sm p-6 relative'
|
||||
>
|
||||
<DarkModeButton/>
|
||||
<i className='fas fa-copyright' /> {`${copyrightDate}`} <span><i className='mx-1 animate-pulse fas fa-heart'/> <a href={siteConfig('LINK')} className='underline font-bold text-gray-500 dark:text-gray-300 '>{siteConfig('AUTHOR')}</a>.<br/>
|
||||
|
||||
{siteConfig('BEI_AN') && <><i className='fas fa-shield-alt'/> <a href='https://beian.miit.gov.cn/' className='mr-2'>{siteConfig('BEI_AN')}</a><br/></>}
|
||||
|
||||
<span className='hidden busuanzi_container_site_pv'>
|
||||
<i className='fas fa-eye'/><span className='px-1 busuanzi_value_site_pv'> </span> </span>
|
||||
<span className='pl-2 hidden busuanzi_container_site_uv'>
|
||||
<i className='fas fa-users'/> <span className='px-1 busuanzi_value_site_uv'> </span> </span>
|
||||
<br/>
|
||||
<h1>{title}</h1>
|
||||
<span className='text-xs font-serif'>Powered by <a href='https://github.com/tangly1024/NotionNext' className='underline text-gray-500 dark:text-gray-300'>NotionNext {siteConfig('VERSION')}</a>.</span></span>
|
||||
</footer>
|
||||
)
|
||||
}
|
||||
|
||||
export default Footer
|
||||
136
themes/magzine/components/Header.js
Normal file
136
themes/magzine/components/Header.js
Normal file
@@ -0,0 +1,136 @@
|
||||
import Collapse from '@/components/Collapse'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import throttle from 'lodash.throttle'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import CONFIG from '../config'
|
||||
import LogoBar from './LogoBar'
|
||||
import { MenuBarMobile } from './MenuBarMobile'
|
||||
import { MenuItemDrop } from './MenuItemDrop'
|
||||
|
||||
/**
|
||||
* 顶部导航栏 + 菜单
|
||||
* @param {} param0
|
||||
* @returns
|
||||
*/
|
||||
export default function Header(props) {
|
||||
const { customNav, customMenu } = props
|
||||
const [isOpen, changeShow] = useState(false)
|
||||
const collapseRef = useRef(null)
|
||||
|
||||
const { locale } = useGlobal()
|
||||
|
||||
const defaultLinks = [
|
||||
{
|
||||
icon: 'fas fa-th',
|
||||
name: locale.COMMON.CATEGORY,
|
||||
href: '/category',
|
||||
show: CONFIG.MENU_CATEGORY
|
||||
},
|
||||
{
|
||||
icon: 'fas fa-tag',
|
||||
name: locale.COMMON.TAGS,
|
||||
href: '/tag',
|
||||
show: CONFIG.MENU_TAG
|
||||
},
|
||||
{
|
||||
icon: 'fas fa-archive',
|
||||
name: locale.NAV.ARCHIVE,
|
||||
href: '/archive',
|
||||
show: CONFIG.MENU_ARCHIVE
|
||||
},
|
||||
{
|
||||
icon: 'fas fa-search',
|
||||
name: locale.NAV.SEARCH,
|
||||
href: '/search',
|
||||
show: CONFIG.MENU_SEARCH
|
||||
}
|
||||
]
|
||||
|
||||
let links = defaultLinks.concat(customNav)
|
||||
|
||||
const toggleMenuOpen = () => {
|
||||
changeShow(!isOpen)
|
||||
}
|
||||
|
||||
// 向下滚动时,调整导航条高度
|
||||
useEffect(() => {
|
||||
scrollTrigger()
|
||||
window.addEventListener('scroll', scrollTrigger)
|
||||
return () => {
|
||||
window.removeEventListener('scroll', scrollTrigger)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const throttleMs = 150
|
||||
|
||||
const scrollTrigger = throttle(() => {
|
||||
const scrollS = window.scrollY
|
||||
const nav = document.querySelector('#top-navbar')
|
||||
|
||||
const narrowNav = scrollS > 50
|
||||
if (narrowNav) {
|
||||
nav && nav.classList.replace('h-20', 'h-14')
|
||||
} else {
|
||||
nav && nav.classList.replace('h-14', 'h-20')
|
||||
}
|
||||
}, throttleMs)
|
||||
|
||||
// 如果 开启自定义菜单,则覆盖Page生成的菜单
|
||||
if (siteConfig('CUSTOM_MENU')) {
|
||||
links = customMenu
|
||||
}
|
||||
|
||||
if (!links || links.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
id='top-navbar-wrapper'
|
||||
className={
|
||||
'sticky top-0 w-full z-40 shadow bg-white dark:bg-hexo-black-gray '
|
||||
}>
|
||||
{/* 导航栏菜单内容 */}
|
||||
<div
|
||||
id='top-navbar'
|
||||
className='px-4 flex w-full mx-auto max-w-screen-xl h-20 transition-all duration-200 items-between'>
|
||||
{/* 左侧图标Logo */}
|
||||
<LogoBar {...props} />
|
||||
|
||||
{/* 移动端折叠按钮 */}
|
||||
<div className='mr-1 flex md:hidden justify-end items-center text-lg space-x-4 font-serif dark:text-gray-200'>
|
||||
<div onClick={toggleMenuOpen} className='cursor-pointer'>
|
||||
{isOpen ? (
|
||||
<i className='fas fa-times' />
|
||||
) : (
|
||||
<i className='fas fa-bars' />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 桌面端顶部菜单 */}
|
||||
<div className='hidden md:flex items-center'>
|
||||
{links &&
|
||||
links?.map(link => <MenuItemDrop key={link?.id} link={link} />)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 移动端折叠菜单 */}
|
||||
<Collapse
|
||||
type='vertical'
|
||||
collapseRef={collapseRef}
|
||||
isOpen={isOpen}
|
||||
className='md:hidden'>
|
||||
<div className='bg-white dark:bg-hexo-black-gray pt-1 py-2 lg:hidden '>
|
||||
<MenuBarMobile
|
||||
{...props}
|
||||
onHeightChange={param =>
|
||||
collapseRef.current?.updateCollapseHeight(param)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Collapse>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
39
themes/magzine/components/InfoCard.js
Normal file
39
themes/magzine/components/InfoCard.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import LazyImage from '@/components/LazyImage'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import Router from 'next/router'
|
||||
import SocialButton from './SocialButton'
|
||||
|
||||
/**
|
||||
* 用户信息卡
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const InfoCard = props => {
|
||||
const { siteInfo } = props
|
||||
return (
|
||||
<div id='info-card' className='py-4'>
|
||||
<div className='items-center justify-start'>
|
||||
<div
|
||||
className='hover:scale-105 transform duration-200 cursor-pointer flex justify-start'
|
||||
onClick={() => {
|
||||
Router.push('/about')
|
||||
}}>
|
||||
<LazyImage
|
||||
src={siteInfo?.icon}
|
||||
width={120}
|
||||
alt={siteConfig('AUTHOR')}
|
||||
/>
|
||||
</div>
|
||||
<div className='text-xl py-2 hover:scale-105 transform duration-200 flex justify-start dark:text-gray-300'>
|
||||
{siteConfig('AUTHOR')}
|
||||
</div>
|
||||
<div className='font-light text-gray-600 mb-2 hover:scale-105 transform duration-200 flex justify-start dark:text-gray-400'>
|
||||
{siteConfig('BIO')}
|
||||
</div>
|
||||
<SocialButton />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default InfoCard
|
||||
29
themes/magzine/components/JumpToTopButton.js
Normal file
29
themes/magzine/components/JumpToTopButton.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import CONFIG from '../config'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
|
||||
/**
|
||||
* 跳转到网页顶部
|
||||
* 当屏幕下滑500像素后会出现该控件
|
||||
* @param targetRef 关联高度的目标html标签
|
||||
* @param showPercent 是否显示百分比
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const JumpToTopButton = ({ showPercent = false, percent, className }) => {
|
||||
if (!siteConfig('MEDIUM_WIDGET_TO_TOP', null, CONFIG)) {
|
||||
return <></>
|
||||
}
|
||||
return (
|
||||
<div
|
||||
id="jump-to-top"
|
||||
data-aos="fade-up"
|
||||
data-aos-duration="300"
|
||||
data-aos-once="false"
|
||||
data-aos-anchor-placement="top-center"
|
||||
className='fixed xl:right-80 right-2 mr-10 bottom-24 z-20'>
|
||||
<i className='fas fa-chevron-up cursor-pointer p-2 rounded-full border bg-white dark:bg-hexo-black-gray' onClick={() => { window.scrollTo({ top: 0, behavior: 'smooth' }) }} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default JumpToTopButton
|
||||
15
themes/magzine/components/LeftMenuBar.js
Normal file
15
themes/magzine/components/LeftMenuBar.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import Link from 'next/link'
|
||||
|
||||
export default function LeftMenuBar () {
|
||||
return (
|
||||
<div className='w-20 border-r hidden lg:block pt-12'>
|
||||
<section>
|
||||
<Link href='/' legacyBehavior>
|
||||
<div className='text-center cursor-pointer hover:text-black'>
|
||||
<i className='fas fa-home text-gray-500'/>
|
||||
</div>
|
||||
</Link>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
7
themes/magzine/components/LoadingCover.js
Normal file
7
themes/magzine/components/LoadingCover.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function LoadingCover() {
|
||||
return <div id='cover-loading' className={'z-50 opacity-50 pointer-events-none transition-all duration-300'}>
|
||||
<div className='w-full h-screen flex justify-center items-center'>
|
||||
<i className="fa-solid fa-spinner text-2xl text-black dark:text-white animate-spin"> </i>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
20
themes/magzine/components/LogoBar.js
Normal file
20
themes/magzine/components/LogoBar.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import Link from 'next/link'
|
||||
|
||||
export default function LogoBar(props) {
|
||||
const { siteInfo } = props
|
||||
return (
|
||||
<div id='top-wrapper' className='w-full flex items-center '>
|
||||
<Link href='/' className='flex text-md md:text-xl dark:text-gray-200'>
|
||||
{/* <LazyImage
|
||||
src={siteInfo?.icon}
|
||||
width={24}
|
||||
height={20}
|
||||
alt={siteConfig('AUTHOR')}
|
||||
className='mr-2 hidden md:block rounded-full'
|
||||
/> */}
|
||||
{siteConfig('TITLE')}
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
54
themes/magzine/components/MenuBarMobile.js
Normal file
54
themes/magzine/components/MenuBarMobile.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import CONFIG from '../config'
|
||||
import { MenuItemCollapse } from './MenuItemCollapse'
|
||||
|
||||
export const MenuBarMobile = props => {
|
||||
const { customMenu, customNav } = props
|
||||
const { locale } = useGlobal()
|
||||
|
||||
let links = [
|
||||
// { name: locale.NAV.INDEX, href: '/' || '/', show: true },
|
||||
{
|
||||
name: locale.COMMON.CATEGORY,
|
||||
href: '/category',
|
||||
show: siteConfig('MEDIUM_MENU_CATEGORY', null, CONFIG)
|
||||
},
|
||||
{
|
||||
name: locale.COMMON.TAGS,
|
||||
href: '/tag',
|
||||
show: siteConfig('MEDIUM_MENU_TAG', null, CONFIG)
|
||||
},
|
||||
{
|
||||
name: locale.NAV.ARCHIVE,
|
||||
href: '/archive',
|
||||
show: siteConfig('MEDIUM_MENU_ARCHIVE', null, CONFIG)
|
||||
}
|
||||
// { name: locale.NAV.SEARCH, href: '/search', show: siteConfig('MENU_SEARCH', null, CONFIG) }
|
||||
]
|
||||
|
||||
if (customNav) {
|
||||
links = links.concat(customNav)
|
||||
}
|
||||
|
||||
// 如果 开启自定义菜单,则不再使用 Page生成菜单。
|
||||
if (siteConfig('CUSTOM_MENU')) {
|
||||
links = customMenu
|
||||
}
|
||||
|
||||
if (!links || links.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<nav id='nav' className=' text-md'>
|
||||
{links?.map((link, index) => (
|
||||
<MenuItemCollapse
|
||||
onHeightChange={props.onHeightChange}
|
||||
key={index}
|
||||
link={link}
|
||||
/>
|
||||
))}
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
97
themes/magzine/components/MenuItemCollapse.js
Normal file
97
themes/magzine/components/MenuItemCollapse.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import Collapse from '@/components/Collapse'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useState } from 'react'
|
||||
|
||||
/**
|
||||
* 折叠菜单
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
export const MenuItemCollapse = props => {
|
||||
const { link } = props
|
||||
const [show, changeShow] = useState(false)
|
||||
const hasSubMenu = link?.subMenus?.length > 0
|
||||
|
||||
const [isOpen, changeIsOpen] = useState(false)
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
if (!link || !link.show) {
|
||||
return null
|
||||
}
|
||||
|
||||
const selected = router.pathname === link.href || router.asPath === link.href
|
||||
|
||||
const toggleShow = () => {
|
||||
changeShow(!show)
|
||||
}
|
||||
|
||||
const toggleOpenSubMenu = () => {
|
||||
changeIsOpen(!isOpen)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={
|
||||
(selected
|
||||
? 'bg-gray-600 text-white hover:text-white'
|
||||
: 'hover:text-gray-600') +
|
||||
' px-5 w-full text-left duration-200 dark:bg-hexo-black-gray dark:border-black'
|
||||
}
|
||||
onClick={toggleShow}>
|
||||
{!hasSubMenu && (
|
||||
<Link
|
||||
href={link?.href}
|
||||
target={link?.target}
|
||||
className='py-2 w-full my-auto items-center justify-between flex '>
|
||||
<div>
|
||||
<div className={`${link.icon} text-center w-4 mr-4`} />
|
||||
{link.name}
|
||||
</div>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{hasSubMenu && (
|
||||
<div
|
||||
onClick={hasSubMenu ? toggleOpenSubMenu : null}
|
||||
className='py-2 font-extralight flex justify-between cursor-pointer dark:text-gray-200 no-underline tracking-widest'>
|
||||
<div>
|
||||
<div className={`${link.icon} text-center w-4 mr-4`} />
|
||||
{link.name}
|
||||
</div>
|
||||
<div className='inline-flex items-center '>
|
||||
<i
|
||||
className={`px-2 fas fa-chevron-right transition-all duration-200 ${isOpen ? 'rotate-90' : ''}`}></i>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 折叠子菜单 */}
|
||||
{hasSubMenu && (
|
||||
<Collapse isOpen={isOpen} onHeightChange={props.onHeightChange}>
|
||||
{link?.subMenus?.map(sLink => {
|
||||
return (
|
||||
<div
|
||||
key={sLink.id}
|
||||
className='
|
||||
not:last-child:border-b-0 border-b dark:border-gray-800 py-2 px-14 cursor-pointer hover:bg-gray-100 dark:text-gray-200
|
||||
font-extralight dark:bg-black text-left justify-start text-gray-600 bg-gray-50 dark:hover:bg-gray-900 tracking-widest transition-all duration-200'>
|
||||
<Link href={sLink.href} target={link?.target}>
|
||||
<div>
|
||||
<div
|
||||
className={`${sLink.icon} text-center w-3 mr-3 text-xs`}
|
||||
/>
|
||||
{sLink.title}
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</Collapse>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
76
themes/magzine/components/MenuItemDrop.js
Normal file
76
themes/magzine/components/MenuItemDrop.js
Normal file
@@ -0,0 +1,76 @@
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useState } from 'react'
|
||||
|
||||
export const MenuItemDrop = ({ link }) => {
|
||||
const [show, changeShow] = useState(false)
|
||||
// const show = true
|
||||
// const changeShow = () => {}
|
||||
const router = useRouter()
|
||||
|
||||
if (!link || !link.show) {
|
||||
return null
|
||||
}
|
||||
const hasSubMenu = link?.subMenus?.length > 0
|
||||
const selected = router.pathname === link.href || router.asPath === link.href
|
||||
|
||||
return (
|
||||
<li
|
||||
className='cursor-pointer list-none items-center flex mx-2'
|
||||
onMouseOver={() => changeShow(true)}
|
||||
onMouseOut={() => changeShow(false)}>
|
||||
{hasSubMenu && (
|
||||
<div
|
||||
className={
|
||||
'px-3 h-full whitespace-nowrap duration-300 text-sm justify-between dark:text-gray-300 cursor-pointer flex flex-nowrap items-center ' +
|
||||
(selected
|
||||
? 'bg-gray-600 text-white hover:text-white'
|
||||
: 'hover:text-gray-600')
|
||||
}>
|
||||
<div>
|
||||
{link?.icon && <i className={link?.icon} />} {link?.name}
|
||||
{hasSubMenu && (
|
||||
<i
|
||||
className={`px-2 fas fa-chevron-down duration-500 transition-all ${show ? ' rotate-180' : ''}`}></i>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!hasSubMenu && (
|
||||
<div
|
||||
className={
|
||||
'px-3 h-full whitespace-nowrap duration-300 text-sm justify-between dark:text-gray-300 cursor-pointer flex flex-nowrap items-center ' +
|
||||
(selected
|
||||
? 'bg-gray-600 text-white hover:text-white'
|
||||
: 'hover:text-gray-600')
|
||||
}>
|
||||
<Link href={link?.href} target={link?.target}>
|
||||
{link?.icon && <i className={link?.icon} />} {link?.name}
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 子菜单 */}
|
||||
{hasSubMenu && (
|
||||
<ul
|
||||
className={`${show ? 'visible opacity-100 top-12 ' : 'invisible opacity-0 top-10 '} border-gray-100 bg-white dark:bg-black dark:border-gray-800 transition-all duration-300 z-20 absolute block drop-shadow-lg `}>
|
||||
{link?.subMenus?.map(sLink => {
|
||||
return (
|
||||
<li
|
||||
key={sLink.id}
|
||||
className='not:last-child:border-b-0 border-b text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-900 tracking-widest transition-all duration-200 dark:border-gray-800 py-3 pr-6 pl-3'>
|
||||
<Link href={sLink.href} target={link?.target}>
|
||||
<span className='text-xs font-extralight'>
|
||||
{link?.icon && <i className={sLink?.icon}> </i>}
|
||||
{sLink.title}
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
29
themes/magzine/components/MenuItemMobileNormal.js
Normal file
29
themes/magzine/components/MenuItemMobileNormal.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
export const NormalMenu = props => {
|
||||
const { link } = props
|
||||
const router = useRouter()
|
||||
|
||||
if (!link || !link.show) {
|
||||
return null
|
||||
}
|
||||
|
||||
const selected = router.pathname === link.href || router.asPath === link.href
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={`${link.href}`}
|
||||
title={link.href}
|
||||
href={link.href}
|
||||
className={
|
||||
'py-0.5 duration-500 justify-between text-gray-500 dark:text-gray-300 hover:text-black hover:underline cursor-pointer flex flex-nowrap items-center ' +
|
||||
(selected ? 'text-black' : ' ')
|
||||
}>
|
||||
<div className='my-auto items-center justify-center flex '>
|
||||
<div className={'hover:text-black'}>{link.name}</div>
|
||||
</div>
|
||||
{link.slot}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
30
themes/magzine/components/MenuItemPCNormal.js
Normal file
30
themes/magzine/components/MenuItemPCNormal.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
export const MenuItemPCNormal = props => {
|
||||
const { link } = props
|
||||
const router = useRouter()
|
||||
const selected = router.pathname === link.href || router.asPath === link.href
|
||||
if (!link || !link.show) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={`${link.id}-${link.href}`}
|
||||
title={link.href}
|
||||
href={link.href}
|
||||
className={
|
||||
'px-2 duration-300 text-sm justify-between dark:text-gray-300 cursor-pointer flex flex-nowrap items-center ' +
|
||||
(selected
|
||||
? 'bg-gray-600 text-white hover:text-white'
|
||||
: 'hover:text-gray-600')
|
||||
}>
|
||||
<div className='items-center justify-center flex '>
|
||||
<i className={link.icon} />
|
||||
<div className='ml-2 whitespace-nowrap'>{link.name}</div>
|
||||
</div>
|
||||
{link.slot}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
55
themes/magzine/components/PaginationSimple.js
Normal file
55
themes/magzine/components/PaginationSimple.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
/**
|
||||
* 简易翻页插件
|
||||
* @param page 当前页码
|
||||
* @param totalPage 是否有下一页
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const PaginationSimple = ({ page, totalPage }) => {
|
||||
const { locale } = useGlobal()
|
||||
const router = useRouter()
|
||||
const currentPage = +page
|
||||
const showNext = currentPage < totalPage
|
||||
const pagePrefix = router.asPath
|
||||
.split('?')[0]
|
||||
.replace(/\/page\/[1-9]\d*/, '')
|
||||
.replace(/\/$/, '')
|
||||
|
||||
return (
|
||||
<div className='my-10 flex justify-between font-medium text-black dark:text-gray-100 space-x-2'>
|
||||
<Link
|
||||
href={{
|
||||
pathname:
|
||||
currentPage === 2
|
||||
? `${pagePrefix}/`
|
||||
: `${pagePrefix}/page/${currentPage - 1}`,
|
||||
query: router.query.s ? { s: router.query.s } : {}
|
||||
}}
|
||||
passHref
|
||||
rel='prev'
|
||||
className={`${
|
||||
currentPage === 1 ? 'invisible' : 'block'
|
||||
} text-center w-full duration-200 px-4 py-2 hover:border-gray-500 border-b-2 hover:font-bold`}>
|
||||
←{locale.PAGINATION.PREV}
|
||||
</Link>
|
||||
<Link
|
||||
href={{
|
||||
pathname: `${pagePrefix}/page/${currentPage + 1}`,
|
||||
query: router.query.s ? { s: router.query.s } : {}
|
||||
}}
|
||||
passHref
|
||||
rel='next'
|
||||
className={`${
|
||||
+showNext ? 'block' : 'invisible'
|
||||
} text-center w-full duration-200 px-4 py-2 hover:border-gray-500 border-b-2 hover:font-bold`}>
|
||||
{locale.PAGINATION.NEXT}→
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default PaginationSimple
|
||||
44
themes/magzine/components/Progress.js
Normal file
44
themes/magzine/components/Progress.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { isBrowser } from '@/lib/utils'
|
||||
|
||||
/**
|
||||
* 顶部页面阅读进度条
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const Progress = ({ targetRef, showPercent = true }) => {
|
||||
const currentRef = targetRef?.current || targetRef
|
||||
const [percent, changePercent] = useState(0)
|
||||
const scrollListener = () => {
|
||||
const target = currentRef || (isBrowser && document.getElementById('article-wrapper'))
|
||||
if (target) {
|
||||
const clientHeight = target.clientHeight
|
||||
const scrollY = window.pageYOffset
|
||||
const fullHeight = clientHeight - window.outerHeight
|
||||
let per = parseFloat(((scrollY / fullHeight) * 100).toFixed(0))
|
||||
if (per > 100) per = 100
|
||||
if (per < 0) per = 0
|
||||
changePercent(per)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('scroll', scrollListener)
|
||||
return () => document.removeEventListener('scroll', scrollListener)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="h-4 w-full shadow-2xl bg-hexo-light-gray dark:bg-black">
|
||||
<div
|
||||
className="h-4 bg-gray-600 duration-200"
|
||||
style={{ width: `${percent}%` }}
|
||||
>
|
||||
{showPercent && (
|
||||
<div className="text-right text-white text-xs">{percent}%</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Progress
|
||||
36
themes/magzine/components/RevolverMaps.js
Normal file
36
themes/magzine/components/RevolverMaps.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
export default function RevolverMaps () {
|
||||
const [load, changeLoad] = useState(false)
|
||||
useEffect(() => {
|
||||
if (!load) {
|
||||
initRevolverMaps()
|
||||
changeLoad(true)
|
||||
}
|
||||
})
|
||||
return <div id="revolvermaps" className='p-4'/>
|
||||
}
|
||||
|
||||
function initRevolverMaps () {
|
||||
if (screen.width >= 768) {
|
||||
Promise.all([
|
||||
loadExternalResource('https://rf.revolvermaps.com/0/0/8.js?i=5jnp1havmh9&m=0&c=ff0000&cr1=ffffff&f=arial&l=33')
|
||||
]).then(() => {
|
||||
// console.log('地图加载完成')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 封装异步加载资源的方法
|
||||
function loadExternalResource (url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const container = document.getElementById('revolvermaps')
|
||||
const tag = document.createElement('script')
|
||||
tag.src = url
|
||||
if (tag) {
|
||||
tag.onload = () => resolve(url)
|
||||
tag.onerror = () => reject(url)
|
||||
container.appendChild(tag)
|
||||
}
|
||||
})
|
||||
}
|
||||
86
themes/magzine/components/SearchInput.js
Normal file
86
themes/magzine/components/SearchInput.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import { useImperativeHandle, useRef, useState } from 'react'
|
||||
let lock = false
|
||||
|
||||
const SearchInput = ({ currentTag, currentSearch, cRef, className }) => {
|
||||
const [onLoading, setLoadingState] = useState(false)
|
||||
const router = useRouter()
|
||||
const searchInputRef = useRef()
|
||||
useImperativeHandle(cRef, () => {
|
||||
return {
|
||||
focus: () => {
|
||||
searchInputRef?.current?.focus()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const handleSearch = () => {
|
||||
const key = searchInputRef.current.value
|
||||
|
||||
if (key && key !== '') {
|
||||
setLoadingState(true)
|
||||
location.href = '/search/' + key
|
||||
} else {
|
||||
router.push({ pathname: '/' }).then(r => {
|
||||
})
|
||||
}
|
||||
}
|
||||
const handleKeyUp = (e) => {
|
||||
if (e.keyCode === 13) { // 回车
|
||||
handleSearch(searchInputRef.current.value)
|
||||
} else if (e.keyCode === 27) { // ESC
|
||||
cleanSearch()
|
||||
}
|
||||
}
|
||||
const cleanSearch = () => {
|
||||
searchInputRef.current.value = ''
|
||||
}
|
||||
|
||||
const [showClean, setShowClean] = useState(false)
|
||||
const updateSearchKey = (val) => {
|
||||
if (lock) {
|
||||
return
|
||||
}
|
||||
searchInputRef.current.value = val
|
||||
|
||||
if (val) {
|
||||
setShowClean(true)
|
||||
} else {
|
||||
setShowClean(false)
|
||||
}
|
||||
}
|
||||
function lockSearchInput () {
|
||||
lock = true
|
||||
}
|
||||
|
||||
function unLockSearchInput () {
|
||||
lock = false
|
||||
}
|
||||
|
||||
return <div className={'flex w-full bg-gray-100 ' + className}>
|
||||
<input
|
||||
ref={searchInputRef}
|
||||
type='text'
|
||||
className={'outline-none w-full text-sm pl-2 transition focus:shadow-lg font-light leading-10 text-black bg-gray-100 dark:bg-gray-900 dark:text-white'}
|
||||
onKeyUp={handleKeyUp}
|
||||
onCompositionStart={lockSearchInput}
|
||||
onCompositionUpdate={lockSearchInput}
|
||||
onCompositionEnd={unLockSearchInput}
|
||||
onChange={e => updateSearchKey(e.target.value)}
|
||||
defaultValue={currentSearch}
|
||||
/>
|
||||
|
||||
<div className='-ml-8 cursor-pointer float-right items-center justify-center py-2'
|
||||
onClick={handleSearch}>
|
||||
<i className={`hover:text-black transform duration-200 text-gray-500 dark:hover:text-gray-300 cursor-pointer fas ${onLoading ? 'fa-spinner animate-spin' : 'fa-search'} `} />
|
||||
</div>
|
||||
|
||||
{(showClean &&
|
||||
<div className='-ml-12 cursor-pointer float-right items-center justify-center py-2'>
|
||||
<i className='fas fa-times hover:text-black transform duration-200 text-gray-400 cursor-pointer dark:hover:text-gray-300' onClick={cleanSearch} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
|
||||
export default SearchInput
|
||||
104
themes/magzine/components/SocialButton.js
Normal file
104
themes/magzine/components/SocialButton.js
Normal file
@@ -0,0 +1,104 @@
|
||||
import { siteConfig } from '@/lib/config'
|
||||
|
||||
/**
|
||||
* 社交联系方式按钮组
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const SocialButton = () => {
|
||||
return (
|
||||
<div className='space-x-3 text-xl text-gray-600 dark:text-gray-400 flex-wrap flex justify-start '>
|
||||
{siteConfig('CONTACT_GITHUB') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title={'github'}
|
||||
href={siteConfig('CONTACT_GITHUB')}>
|
||||
<i className='fab fa-github transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
{siteConfig('CONTACT_TWITTER') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title={'twitter'}
|
||||
href={siteConfig('CONTACT_TWITTER')}>
|
||||
<i className='fab fa-twitter transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
{siteConfig('CONTACT_TELEGRAM') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
href={siteConfig('CONTACT_TELEGRAM')}
|
||||
title={'telegram'}>
|
||||
<i className='fab fa-telegram transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
{siteConfig('CONTACT_LINKEDIN') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
href={siteConfig('CONTACT_LINKEDIN')}
|
||||
title={'linkedIn'}>
|
||||
<i className='transform hover:scale-125 duration-150 fab fa-linkedin dark:hover:text-indigo-400 hover:text-indigo-600' />
|
||||
</a>
|
||||
)}
|
||||
{siteConfig('CONTACT_WEIBO') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title={'weibo'}
|
||||
href={siteConfig('CONTACT_WEIBO')}>
|
||||
<i className='fab fa-weibo transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
{siteConfig('CONTACT_INSTAGRAM') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title={'instagram'}
|
||||
href={siteConfig('CONTACT_INSTAGRAM')}>
|
||||
<i className='fab fa-instagram transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
{siteConfig('CONTACT_EMAIL') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title={'email'}
|
||||
href={`mailto:${siteConfig('CONTACT_EMAIL')}`}>
|
||||
<i className='fas fa-envelope transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
{JSON.parse(siteConfig('ENABLE_RSS')) && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title={'RSS'}
|
||||
href={'/rss/feed.xml'}>
|
||||
<i className='fas fa-rss transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
{siteConfig('CONTACT_BILIBILI') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title={'bilibili'}
|
||||
href={siteConfig('CONTACT_BILIBILI')}>
|
||||
<i className='fab fa-bilibili transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
{siteConfig('CONTACT_YOUTUBE') && (
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title={'youtube'}
|
||||
href={siteConfig('CONTACT_YOUTUBE')}>
|
||||
<i className='fab fa-youtube transform hover:scale-125 duration-150 hover:text-gray-600' />
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default SocialButton
|
||||
30
themes/magzine/components/TagGroups.js
Normal file
30
themes/magzine/components/TagGroups.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import TagItemMini from './TagItemMini'
|
||||
|
||||
/**
|
||||
* 标签组
|
||||
* @param tags
|
||||
* @param currentTag
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const TagGroups = ({ tagOptions, currentTag }) => {
|
||||
const { locale } = useGlobal()
|
||||
if (!tagOptions) return <></>
|
||||
return (
|
||||
<div id='tags-group' className='dark:border-gray-600 py-4'>
|
||||
<div className='mb-2'>
|
||||
<i className='mr-2 fas fa-tag' />
|
||||
{locale.COMMON.TAGS}
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
{tagOptions?.map(tag => {
|
||||
const selected = tag.name === currentTag
|
||||
return <TagItemMini key={tag.name} tag={tag} selected={selected} />
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default TagGroups
|
||||
21
themes/magzine/components/TagItemMini.js
Normal file
21
themes/magzine/components/TagItemMini.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import Link from 'next/link'
|
||||
|
||||
const TagItemMini = ({ tag, selected = false }) => {
|
||||
return (
|
||||
<Link
|
||||
key={tag}
|
||||
href={selected ? '/' : `/tag/${encodeURIComponent(tag.name)}`}
|
||||
passHref
|
||||
className={`cursor-pointer inline-block rounded hover:bg-gray-500 hover:text-white duration-200
|
||||
mr-2 py-1 px-2 text-xs whitespace-nowrap dark:hover:text-white
|
||||
${selected
|
||||
? 'text-white dark:text-gray-300 bg-black dark:bg-black dark:hover:bg-gray-900'
|
||||
: `text-gray-600 hover:shadow-xl dark:border-gray-400 notion-${tag.color}_background dark:bg-gray-800`}` }>
|
||||
|
||||
<div className='font-light dark:text-gray-400'>{selected && <i className='mr-1 fas fa-tag'/>} {tag.name + (tag.count ? `(${tag.count})` : '')} </div>
|
||||
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
export default TagItemMini
|
||||
48
themes/magzine/components/TocDrawer.js
Normal file
48
themes/magzine/components/TocDrawer.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { useMagzineGlobal } from '..'
|
||||
import Catalog from './Catalog'
|
||||
|
||||
/**
|
||||
* 悬浮抽屉目录
|
||||
* @param toc
|
||||
* @param post
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const TocDrawer = ({ post, cRef }) => {
|
||||
const { tocVisible, changeTocVisible } = useMagzineGlobal()
|
||||
const switchVisible = () => {
|
||||
changeTocVisible(!tocVisible)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<div id='medium-toc-float' className='fixed top-0 right-0 z-40'>
|
||||
{/* 侧边菜单 */}
|
||||
<div
|
||||
className={
|
||||
(tocVisible
|
||||
? 'animate__slideInRight '
|
||||
: ' -mr-72 animate__slideOutRight') +
|
||||
' overflow-y-hidden shadow-card w-60 duration-200 fixed right-1 bottom-16 rounded py-2 bg-white dark:bg-gray-600'
|
||||
}>
|
||||
{post && (
|
||||
<>
|
||||
<div className='dark:text-gray-400 text-gray-600 h-56'>
|
||||
<Catalog toc={post.toc} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{/* 背景蒙版 */}
|
||||
<div
|
||||
id='right-drawer-background'
|
||||
className={
|
||||
(tocVisible ? 'block' : 'hidden') +
|
||||
' fixed top-0 left-0 z-30 w-full h-full'
|
||||
}
|
||||
onClick={switchVisible}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default TocDrawer
|
||||
110
themes/magzine/components/TopNavBar.js
Normal file
110
themes/magzine/components/TopNavBar.js
Normal file
@@ -0,0 +1,110 @@
|
||||
import Collapse from '@/components/Collapse'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { useRef, useState } from 'react'
|
||||
import CONFIG from '../config'
|
||||
import LogoBar from './LogoBar'
|
||||
import { MenuBarMobile } from './MenuBarMobile'
|
||||
import { MenuItemDrop } from './MenuItemDrop'
|
||||
|
||||
/**
|
||||
* 顶部导航栏 + 菜单
|
||||
* @param {} param0
|
||||
* @returns
|
||||
*/
|
||||
export default function TopNavBar(props) {
|
||||
const { className, customNav, customMenu } = props
|
||||
const [isOpen, changeShow] = useState(false)
|
||||
const collapseRef = useRef(null)
|
||||
|
||||
const { locale } = useGlobal()
|
||||
|
||||
const defaultLinks = [
|
||||
{
|
||||
icon: 'fas fa-th',
|
||||
name: locale.COMMON.CATEGORY,
|
||||
href: '/category',
|
||||
show: siteConfig('MEDIUM_MENU_CATEGORY', null, CONFIG)
|
||||
},
|
||||
{
|
||||
icon: 'fas fa-tag',
|
||||
name: locale.COMMON.TAGS,
|
||||
href: '/tag',
|
||||
show: siteConfig('MEDIUM_MENU_TAG', null, CONFIG)
|
||||
},
|
||||
{
|
||||
icon: 'fas fa-archive',
|
||||
name: locale.NAV.ARCHIVE,
|
||||
href: '/archive',
|
||||
show: siteConfig('MEDIUM_MENU_ARCHIVE', null, CONFIG)
|
||||
},
|
||||
{
|
||||
icon: 'fas fa-search',
|
||||
name: locale.NAV.SEARCH,
|
||||
href: '/search',
|
||||
show: siteConfig('MEDIUM_MENU_SEARCH', null, CONFIG)
|
||||
}
|
||||
]
|
||||
|
||||
let links = defaultLinks.concat(customNav)
|
||||
|
||||
const toggleMenuOpen = () => {
|
||||
changeShow(!isOpen)
|
||||
}
|
||||
|
||||
// 如果 开启自定义菜单,则覆盖Page生成的菜单
|
||||
if (siteConfig('CUSTOM_MENU')) {
|
||||
links = customMenu
|
||||
}
|
||||
|
||||
if (!links || links.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
id='top-nav'
|
||||
className={'sticky top-0 lg:relative w-full z-40 ' + className}>
|
||||
{/* 移动端折叠菜单 */}
|
||||
<Collapse
|
||||
type='vertical'
|
||||
collapseRef={collapseRef}
|
||||
isOpen={isOpen}
|
||||
className='md:hidden'>
|
||||
<div className='bg-white dark:bg-hexo-black-gray pt-1 py-2 lg:hidden '>
|
||||
<MenuBarMobile
|
||||
{...props}
|
||||
onHeightChange={param =>
|
||||
collapseRef.current?.updateCollapseHeight(param)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Collapse>
|
||||
|
||||
{/* 导航栏菜单 */}
|
||||
<div className='flex w-full h-12 shadow bg-white dark:bg-hexo-black-gray px-7 items-between'>
|
||||
{/* 左侧图标Logo */}
|
||||
<LogoBar {...props} />
|
||||
|
||||
{/* 折叠按钮、仅移动端显示 */}
|
||||
<div className='mr-1 flex md:hidden justify-end items-center text-sm space-x-4 font-serif dark:text-gray-200'>
|
||||
<div onClick={toggleMenuOpen} className='cursor-pointer'>
|
||||
{isOpen ? (
|
||||
<i className='fas fa-times' />
|
||||
) : (
|
||||
<i className='fas fa-bars' />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 桌面端顶部菜单 */}
|
||||
<div className='hidden md:flex'>
|
||||
{links &&
|
||||
links?.map((link, index) => (
|
||||
<MenuItemDrop key={index} link={link} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
24
themes/magzine/config.js
Normal file
24
themes/magzine/config.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const CONFIG = {
|
||||
|
||||
// Style
|
||||
MEDIUM_RIGHT_PANEL_DARK: process.env.NEXT_PUBLIC_MEDIUM_RIGHT_DARK || false, // 右侧面板深色模式
|
||||
|
||||
MEDIUM_POST_LIST_COVER: true, // 文章列表显示图片封面
|
||||
MEDIUM_POST_LIST_PREVIEW: true, // 列表显示文章预览
|
||||
MEDIUM_POST_LIST_CATEGORY: true, // 列表显示文章分类
|
||||
MEDIUM_POST_LIST_TAG: true, // 列表显示文章标签
|
||||
|
||||
MEDIUM_POST_DETAIL_CATEGORY: true, // 文章显示分类
|
||||
MEDIUM_POST_DETAIL_TAG: true, // 文章显示标签
|
||||
|
||||
// 菜单
|
||||
MEDIUM_MENU_CATEGORY: true, // 显示分类
|
||||
MEDIUM_MENU_TAG: true, // 显示标签
|
||||
MEDIUM_MENU_ARCHIVE: true, // 显示归档
|
||||
MEDIUM_MENU_SEARCH: true, // 显示搜索
|
||||
|
||||
// Widget
|
||||
MEDIUM_WIDGET_REVOLVER_MAPS: process.env.NEXT_PUBLIC_WIDGET_REVOLVER_MAPS || 'false', // 地图插件
|
||||
MEDIUM_WIDGET_TO_TOP: true // 跳回顶部
|
||||
}
|
||||
export default CONFIG
|
||||
374
themes/magzine/index.js
Normal file
374
themes/magzine/index.js
Normal file
@@ -0,0 +1,374 @@
|
||||
import Comment from '@/components/Comment'
|
||||
import replaceSearchResult from '@/components/Mark'
|
||||
import NotionPage from '@/components/NotionPage'
|
||||
import ShareBar from '@/components/ShareBar'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { isBrowser } from '@/lib/utils'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import { createContext, useContext, useEffect, useState } from 'react'
|
||||
import Announcement from './components/Announcement'
|
||||
import ArticleAround from './components/ArticleAround'
|
||||
import ArticleInfo from './components/ArticleInfo'
|
||||
import { ArticleLock } from './components/ArticleLock'
|
||||
import BlogArchiveItem from './components/BlogArchiveItem'
|
||||
import BlogPostCardHorizontal from './components/BlogPostCardHorizontal'
|
||||
import BlogPostCardTop from './components/BlogPostCardTop'
|
||||
import BlogPostListPage from './components/BlogPostListPage'
|
||||
import BlogPostListScroll from './components/BlogPostListScroll'
|
||||
import Catalog from './components/Catalog'
|
||||
import CategoryGroup from './components/CategoryGroup'
|
||||
import CategoryItem from './components/CategoryItem'
|
||||
import Footer from './components/Footer'
|
||||
import Header from './components/Header'
|
||||
import InfoCard from './components/InfoCard'
|
||||
import SearchInput from './components/SearchInput'
|
||||
import TagGroups from './components/TagGroups'
|
||||
import TagItemMini from './components/TagItemMini'
|
||||
import TocDrawer from './components/TocDrawer'
|
||||
import CONFIG from './config'
|
||||
import { Style } from './style'
|
||||
|
||||
// 主题全局状态
|
||||
const ThemeGlobalMagzine = createContext()
|
||||
export const useMagzineGlobal = () => useContext(ThemeGlobalMagzine)
|
||||
|
||||
/**
|
||||
* 基础布局
|
||||
* 采用左右两侧布局,移动端使用顶部导航栏
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const LayoutBase = props => {
|
||||
const { children, showInfoCard = true, post, notice } = props
|
||||
const { locale } = useGlobal()
|
||||
const router = useRouter()
|
||||
const [tocVisible, changeTocVisible] = useState(false)
|
||||
const { onLoading, fullWidth } = useGlobal()
|
||||
const [slotRight, setSlotRight] = useState(null)
|
||||
|
||||
return (
|
||||
<ThemeGlobalMagzine.Provider value={{ tocVisible, changeTocVisible }}>
|
||||
{/* CSS样式 */}
|
||||
<Style />
|
||||
|
||||
<div
|
||||
id='theme-medium'
|
||||
className={`${siteConfig('FONT_STYLE')} bg-white dark:bg-hexo-black-gray w-full h-full min-h-screen justify-center dark:text-gray-300 scroll-smooth`}>
|
||||
<main
|
||||
id='wrapper'
|
||||
className={'relative flex justify-between w-full h-full mx-auto'}>
|
||||
{/* 主区 */}
|
||||
<div id='container-wrapper' className='w-full relative z-10'>
|
||||
<Header {...props} />
|
||||
<div id='main' role='main'>
|
||||
{children}
|
||||
</div>
|
||||
{/* 底部 */}
|
||||
<Footer title={siteConfig('TITLE')} />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</ThemeGlobalMagzine.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页
|
||||
* 首页就是一个博客列表
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const LayoutIndex = props => {
|
||||
const { posts, notice } = props
|
||||
const top = posts[0]
|
||||
const post1 = posts[1]
|
||||
const post2 = posts[2]
|
||||
return (
|
||||
<div className='container mx-auto max-w-7xl'>
|
||||
{/* 首屏文章 */}
|
||||
|
||||
<div className='md:flex justify-between py-10 md:py-16'>
|
||||
<div className='basis-1/2 mb-6'>
|
||||
<BlogPostCardTop post={top} />
|
||||
</div>
|
||||
<div className='px-10'>
|
||||
<div className='flex justify-between px-4 w-full'>
|
||||
<InfoCard {...props} />
|
||||
<Announcement post={notice} />
|
||||
</div>
|
||||
{/* 两篇主要文章 */}
|
||||
<div>
|
||||
<BlogPostCardHorizontal post={post1} />
|
||||
<BlogPostCardHorizontal post={post2} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 博客列表
|
||||
* @returns
|
||||
*/
|
||||
const LayoutPostList = props => {
|
||||
return (
|
||||
<>
|
||||
{siteConfig('POST_LIST_STYLE') === 'page' ? (
|
||||
<BlogPostListPage {...props} />
|
||||
) : (
|
||||
<BlogPostListScroll {...props} />
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const LayoutSlug = props => {
|
||||
const { post, prev, next, lock, validPassword } = props
|
||||
const { locale } = useGlobal()
|
||||
const slotRight = post?.toc && post?.toc?.length >= 3 && (
|
||||
<div key={locale.COMMON.TABLE_OF_CONTENTS}>
|
||||
<Catalog toc={post?.toc} />
|
||||
</div>
|
||||
)
|
||||
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
// 404
|
||||
if (!post) {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
siteConfig('POST_WAITING_TIME_FOR_404') * 1000
|
||||
)
|
||||
}
|
||||
}, [post])
|
||||
|
||||
return (
|
||||
<div {...props}>
|
||||
{/* 文章锁 */}
|
||||
{lock && <ArticleLock validPassword={validPassword} />}
|
||||
|
||||
{!lock && (
|
||||
<div>
|
||||
{/* 文章信息 */}
|
||||
<ArticleInfo {...props} />
|
||||
|
||||
{/* Notion文章主体 */}
|
||||
<article id='article-wrapper' className='px-1 max-w-4xl'>
|
||||
{post && <NotionPage post={post} />}
|
||||
</article>
|
||||
|
||||
{/* 文章底部区域 */}
|
||||
<section>
|
||||
{/* 分享 */}
|
||||
<ShareBar post={post} />
|
||||
{/* 文章分类和标签信息 */}
|
||||
<div className='flex justify-between'>
|
||||
{siteConfig('MEDIUM_POST_DETAIL_CATEGORY', null, CONFIG) &&
|
||||
post?.category && <CategoryItem category={post?.category} />}
|
||||
<div>
|
||||
{siteConfig('MEDIUM_POST_DETAIL_TAG', null, CONFIG) &&
|
||||
post?.tagItems?.map(tag => (
|
||||
<TagItemMini key={tag.name} tag={tag} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{/* 上一篇下一篇文章 */}
|
||||
{post?.type === 'Post' && <ArticleAround prev={prev} next={next} />}
|
||||
{/* 评论区 */}
|
||||
<Comment frontMatter={post} />
|
||||
</section>
|
||||
|
||||
{/* 移动端目录 */}
|
||||
<TocDrawer {...props} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const LayoutSearch = props => {
|
||||
const { locale } = useGlobal()
|
||||
const { keyword } = props
|
||||
const router = useRouter()
|
||||
const currentSearch = keyword || router?.query?.s
|
||||
|
||||
useEffect(() => {
|
||||
if (isBrowser) {
|
||||
replaceSearchResult({
|
||||
doms: document.getElementById('posts-wrapper'),
|
||||
search: keyword,
|
||||
target: {
|
||||
element: 'span',
|
||||
className: 'text-red-500 border-b border-dashed'
|
||||
}
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* 搜索导航栏 */}
|
||||
<div className='py-12'>
|
||||
<div className='pb-4 w-full'>{locale.NAV.SEARCH}</div>
|
||||
<SearchInput currentSearch={currentSearch} {...props} />
|
||||
{!currentSearch && (
|
||||
<>
|
||||
<TagGroups {...props} />
|
||||
<CategoryGroup {...props} />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 文章列表 */}
|
||||
{currentSearch && (
|
||||
<div>
|
||||
{siteConfig('POST_LIST_STYLE') === 'page' ? (
|
||||
<BlogPostListPage {...props} />
|
||||
) : (
|
||||
<BlogPostListScroll {...props} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const LayoutArchive = props => {
|
||||
const { archivePosts } = props
|
||||
return (
|
||||
<>
|
||||
<div className='mb-10 pb-20 md:py-12 py-3 min-h-full'>
|
||||
{Object.keys(archivePosts)?.map(archiveTitle => (
|
||||
<BlogArchiveItem
|
||||
key={archiveTitle}
|
||||
archiveTitle={archiveTitle}
|
||||
archivePosts={archivePosts}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 404
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const Layout404 = props => {
|
||||
return (
|
||||
<>
|
||||
<div className='w-full h-96 py-80 flex justify-center items-center'>
|
||||
404 Not found.
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const LayoutCategoryIndex = props => {
|
||||
const { categoryOptions } = props
|
||||
const { locale } = useGlobal()
|
||||
return (
|
||||
<>
|
||||
<div className='bg-white dark:bg-gray-700 py-10'>
|
||||
<div className='dark:text-gray-200 mb-5'>
|
||||
<i className='mr-4 fas fa-th' />
|
||||
{locale.COMMON.CATEGORY}:
|
||||
</div>
|
||||
<div id='category-list' className='duration-200 flex flex-wrap'>
|
||||
{categoryOptions?.map(category => {
|
||||
return (
|
||||
<Link
|
||||
key={category.name}
|
||||
href={`/category/${category.name}`}
|
||||
passHref
|
||||
legacyBehavior>
|
||||
<div
|
||||
className={
|
||||
'hover:text-black dark:hover:text-white dark:text-gray-300 dark:hover:bg-gray-600 px-5 cursor-pointer py-2 hover:bg-gray-100'
|
||||
}>
|
||||
<i className='mr-4 fas fa-folder' />
|
||||
{category.name}({category.count})
|
||||
</div>
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签列表
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const LayoutTagIndex = props => {
|
||||
const { tagOptions } = props
|
||||
const { locale } = useGlobal()
|
||||
return (
|
||||
<>
|
||||
<div className='bg-white dark:bg-gray-700 py-10'>
|
||||
<div className='dark:text-gray-200 mb-5'>
|
||||
<i className='mr-4 fas fa-tag' />
|
||||
{locale.COMMON.TAGS}:
|
||||
</div>
|
||||
<div id='tags-list' className='duration-200 flex flex-wrap'>
|
||||
{tagOptions?.map(tag => {
|
||||
return (
|
||||
<div key={tag.name} className='p-2'>
|
||||
<TagItemMini key={tag.name} tag={tag} />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Layout404,
|
||||
LayoutArchive,
|
||||
LayoutBase,
|
||||
LayoutCategoryIndex,
|
||||
LayoutIndex,
|
||||
LayoutPostList,
|
||||
LayoutSearch,
|
||||
LayoutSlug,
|
||||
LayoutTagIndex,
|
||||
CONFIG as THEME_CONFIG
|
||||
}
|
||||
18
themes/magzine/style.js
Normal file
18
themes/magzine/style.js
Normal file
@@ -0,0 +1,18 @@
|
||||
/* eslint-disable react/no-unknown-property */
|
||||
/**
|
||||
* 此处样式只对当前主题生效
|
||||
* 此处不支持tailwindCSS的 @apply 语法
|
||||
* @returns
|
||||
*/
|
||||
const Style = () => {
|
||||
return <style jsx global>{`
|
||||
|
||||
// 底色
|
||||
.dark body{
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
`}</style>
|
||||
}
|
||||
|
||||
export { Style }
|
||||
Reference in New Issue
Block a user