mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 15:10:26 +00:00
更改字段
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
import dynamic from 'next/dynamic'
|
||||
|
||||
const NotionPage = dynamic(() => import('@/components/NotionPage'))
|
||||
|
||||
const Announcement = ({ post, className }) => {
|
||||
if (!post) {
|
||||
return <></>
|
||||
}
|
||||
return <>{post && (<div id="announcement-content" className='px-3'>
|
||||
<NotionPage post={post} />
|
||||
</div>)} </>
|
||||
}
|
||||
export default Announcement
|
||||
@@ -11,7 +11,7 @@ import CONFIG from '../config'
|
||||
export const BlogItem = props => {
|
||||
const { post } = props
|
||||
const { NOTION_CONFIG } = useGlobal()
|
||||
const showPageCover = siteConfig('SIMPLE_POST_COVER_ENABLE', false, CONFIG)
|
||||
const showPageCover = siteConfig('TYPOGRAPHY_POST_COVER_ENABLE', false, CONFIG)
|
||||
const showPreview =
|
||||
siteConfig('POST_LIST_PREVIEW', false, NOTION_CONFIG) && post.blockMap
|
||||
return (
|
||||
@@ -81,11 +81,10 @@ export const BlogItem = props => {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main className='text-[var(--primary-color)] dark:text-gray-300 leading-normal mb-6'>
|
||||
<main className='text-[var(--primary-color)] dark:text-gray-300 mb-6 line-clamp-4 overflow-hidden text-ellipsis relative leading-[1.7]'>
|
||||
{!showPreview && (
|
||||
<>
|
||||
{post.summary}
|
||||
{post.summary && <span>...</span>}
|
||||
</>
|
||||
)}
|
||||
{showPreview && post?.blockMap && (
|
||||
|
||||
@@ -20,8 +20,8 @@ export default function BlogListPage(props) {
|
||||
const currentPage = +page
|
||||
|
||||
// 博客列表嵌入广告
|
||||
const SIMPLE_POST_AD_ENABLE = siteConfig(
|
||||
'SIMPLE_POST_AD_ENABLE',
|
||||
const TYPOGRAPHY_POST_AD_ENABLE = siteConfig(
|
||||
'TYPOGRAPHY_POST_AD_ENABLE',
|
||||
false,
|
||||
CONFIG
|
||||
)
|
||||
@@ -39,10 +39,10 @@ export default function BlogListPage(props) {
|
||||
<div id='posts-wrapper'>
|
||||
{posts?.map((p, index) => (
|
||||
<div key={p.id}>
|
||||
{SIMPLE_POST_AD_ENABLE && (index + 1) % 3 === 0 && (
|
||||
{TYPOGRAPHY_POST_AD_ENABLE && (index + 1) % 3 === 0 && (
|
||||
<AdSlot type='in-article' />
|
||||
)}
|
||||
{SIMPLE_POST_AD_ENABLE && index + 1 === 4 && <AdSlot type='flow' />}
|
||||
{TYPOGRAPHY_POST_AD_ENABLE && index + 1 === 4 && <AdSlot type='flow' />}
|
||||
<BlogItem post={p} />
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import LazyImage from '@/components/LazyImage'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import Link from 'next/link'
|
||||
import CONFIG from '../config'
|
||||
import SocialButton from './SocialButton'
|
||||
|
||||
/**
|
||||
* 网站顶部
|
||||
* @returns
|
||||
*/
|
||||
export default function Header(props) {
|
||||
const { siteInfo } = props
|
||||
|
||||
return (
|
||||
<header className='text-center justify-between items-center px-6 bg-white h-80 dark:bg-black relative z-10'>
|
||||
<div className='float-none inline-block py-12'>
|
||||
<Link href='/'>
|
||||
{/* 可使用一张单图作为logo */}
|
||||
<div className='flex space-x-6 justify-center'>
|
||||
<div className='hover:rotate-45 hover:scale-125 transform duration-200 cursor-pointer justify-center items-center flex'>
|
||||
<LazyImage
|
||||
priority={true}
|
||||
src={siteInfo?.icon}
|
||||
className='rounded-full'
|
||||
width={100}
|
||||
height={100}
|
||||
alt={siteConfig('AUTHOR')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='flex-col flex justify-center'>
|
||||
<div className='text-2xl font-serif dark:text-white py-2 hover:scale-105 transform duration-200'>
|
||||
{siteConfig('AUTHOR')}
|
||||
</div>
|
||||
<div
|
||||
className='font-light dark:text-white py-2 hover:scale-105 transform duration-200 text-center'
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: siteConfig('SIMPLE_LOGO_DESCRIPTION', null, CONFIG)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
<div className='flex justify-center'>
|
||||
<SocialButton />
|
||||
</div>
|
||||
<div className='text-xs mt-4 text-gray-500 dark:text-gray-300'>
|
||||
{siteConfig('DESCRIPTION')}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
@@ -29,24 +29,23 @@ export const MenuList = ({ customNav, customMenu }) => {
|
||||
})
|
||||
|
||||
let links = [
|
||||
|
||||
{
|
||||
icon: 'fas fa-archive',
|
||||
name: locale.NAV.ARCHIVE,
|
||||
href: '/archive',
|
||||
show: siteConfig('SIMPLE_MENU_ARCHIVE', null, CONFIG)
|
||||
show: siteConfig('TYPOGRAPHY_MENU_ARCHIVE', null, CONFIG)
|
||||
},
|
||||
{
|
||||
icon: 'fas fa-folder',
|
||||
name: locale.COMMON.CATEGORY,
|
||||
href: '/category',
|
||||
show: siteConfig('SIMPLE_MENU_CATEGORY', null, CONFIG)
|
||||
show: siteConfig('TYPOGRAPHY_MENU_CATEGORY', null, CONFIG)
|
||||
},
|
||||
{
|
||||
icon: 'fas fa-tag',
|
||||
name: locale.COMMON.TAGS,
|
||||
href: '/tag',
|
||||
show: siteConfig('SIMPLE_MENU_TAG', null, CONFIG)
|
||||
show: siteConfig('TYPOGRAPHY_MENU_TAG', null, CONFIG)
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ export default function NavBar(props) {
|
||||
<Link href='/'>
|
||||
<div className='flex flex-col-reverse md:flex-col items-center md:items-start'>
|
||||
<div className='font-bold text-4xl text-center' id='blog-name'>
|
||||
山野
|
||||
{siteConfig('TYPOGRAPHY_BLOG_NAME')}
|
||||
</div>
|
||||
<div className='font-bold text-xl text-center' id='blog-name-en'>
|
||||
{siteConfig('TYPOGRAPHY_BLOG_NAME_EN')}
|
||||
</div>
|
||||
{/* <div className='font-bold text-xl text-center' id='blog-name-en'>
|
||||
Blog
|
||||
</div> */}
|
||||
</div>
|
||||
</Link>
|
||||
</header>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { siteConfig } from '@/lib/config'
|
||||
*/
|
||||
const RecommendPosts = ({ recommendPosts }) => {
|
||||
const { locale } = useGlobal()
|
||||
if (!siteConfig('SIMPLE_ARTICLE_RECOMMEND_POSTS', null, CONFIG) || !recommendPosts || recommendPosts.length < 1) {
|
||||
if (!siteConfig('TYPOGRAPHY_ARTICLE_RECOMMEND_POSTS', null, CONFIG) || !recommendPosts || recommendPosts.length < 1) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import { useImperativeHandle, useRef, useState } from 'react'
|
||||
let lock = false
|
||||
|
||||
const SearchInput = ({ keyword, 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={keyword}
|
||||
/>
|
||||
|
||||
<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
|
||||
@@ -1,22 +1,15 @@
|
||||
const CONFIG = {
|
||||
|
||||
SIMPLE_LOGO_IMG: '/Logo.webp',
|
||||
SIMPLE_TOP_BAR: true, // 显示顶栏
|
||||
SIMPLE_TOP_BAR_CONTENT: process.env.NEXT_PUBLIC_THEME_SIMPLE_TOP_TIPS || '',
|
||||
SIMPLE_LOGO_DESCRIPTION: process.env.NEXT_PUBLIC_THEME_SIMPLE_LOGO_DESCRIPTION || '<div>编程爱好者<br/>/互联网从业者<br/>/知识分享博主</div>',
|
||||
TYPOGRAPHY_POST_AD_ENABLE: process.env.NEXT_PUBLIC_TYPOGRAPHY_POST_AD_ENABLE || false, // 文章列表是否插入广告
|
||||
|
||||
SIMPLE_AUTHOR_LINK: process.env.NEXT_PUBLIC_AUTHOR_LINK || '#',
|
||||
|
||||
SIMPLE_POST_AD_ENABLE: process.env.NEXT_PUBLIC_SIMPLE_POST_AD_ENABLE || false, // 文章列表是否插入广告
|
||||
|
||||
SIMPLE_POST_COVER_ENABLE: process.env.NEXT_PUBLIC_SIMPLE_POST_COVER_ENABLE || false, // 是否展示博客封面
|
||||
|
||||
SIMPLE_ARTICLE_RECOMMEND_POSTS: process.env.NEXT_PUBLIC_SIMPLE_ARTICLE_RECOMMEND_POSTS || true, // 文章详情底部显示推荐
|
||||
TYPOGRAPHY_POST_COVER_ENABLE: process.env.NEXT_PUBLIC_TYPOGRAPHY_POST_COVER_ENABLE || false, // 是否展示博客封面
|
||||
|
||||
TYPOGRAPHY_ARTICLE_RECOMMEND_POSTS: process.env.NEXT_PUBLIC_TYPOGRAPHY_ARTICLE_RECOMMEND_POSTS || true, // 文章详情底部显示推荐
|
||||
TYPOGRAPHY_BLOG_NAME: process.env.NEXT_PUBLIC_TYPOGRAPHY_BLOG_NAME || '活字印刷',
|
||||
TYPOGRAPHY_BLOG_NAME_EN: process.env.NEXT_PUBLIC_TYPOGRAPHY_BLOG_NAME || 'Typography',
|
||||
// 菜单配置
|
||||
SIMPLE_MENU_CATEGORY: true, // 显示分类
|
||||
SIMPLE_MENU_TAG: true, // 显示标签
|
||||
SIMPLE_MENU_ARCHIVE: true, // 显示归档
|
||||
SIMPLE_MENU_SEARCH: true // 显示搜索
|
||||
TYPOGRAPHY_MENU_CATEGORY: true, // 显示分类
|
||||
TYPOGRAPHY_MENU_TAG: true, // 显示标签
|
||||
TYPOGRAPHY_MENU_ARCHIVE: true, // 显示归档
|
||||
}
|
||||
export default CONFIG
|
||||
|
||||
@@ -4,7 +4,6 @@ import NotionPage from '@/components/NotionPage'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { isBrowser } from '@/lib/utils'
|
||||
import { Transition } from '@headlessui/react'
|
||||
import dynamic from 'next/dynamic'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
@@ -40,9 +39,6 @@ const JumpToTopButton = dynamic(() => import('./components/JumpToTopButton'), {
|
||||
ssr: false
|
||||
})
|
||||
const Footer = dynamic(() => import('./components/Footer'), { ssr: false })
|
||||
const SearchInput = dynamic(() => import('./components/SearchInput'), {
|
||||
ssr: false
|
||||
})
|
||||
const WWAds = dynamic(() => import('@/components/WWAds'), { ssr: false })
|
||||
const BlogListPage = dynamic(() => import('./components/BlogListPage'), {
|
||||
ssr: false
|
||||
@@ -96,7 +92,7 @@ const LayoutBase = props => {
|
||||
{onLoading ? (
|
||||
// loading 时显示 spinner
|
||||
<div className='flex items-center justify-center min-h-[500px] w-full'>
|
||||
<div className='animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-gray-900'></div>
|
||||
<div className='animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-gray-900 dark:border-white'></div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
@@ -106,7 +102,7 @@ const LayoutBase = props => {
|
||||
)}
|
||||
<AdSlot type='native' />
|
||||
{/* 移动端页脚 - 显示在底部 */}
|
||||
<div className='md:hidden z-30 dark:bg-black'>
|
||||
<div className='md:hidden z-30 '>
|
||||
<Footer {...props} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -175,9 +171,6 @@ const LayoutSearch = props => {
|
||||
}
|
||||
}, [])
|
||||
|
||||
const slotTop = siteConfig('ALGOLIA_APP_ID') ? null : (
|
||||
<SearchInput {...props} />
|
||||
)
|
||||
|
||||
return <LayoutPostList {...props} slotTop={slotTop} />
|
||||
}
|
||||
@@ -219,7 +212,7 @@ const LayoutSlug = props => {
|
||||
|
||||
{!lock && post && (
|
||||
<div
|
||||
className={`px-2 pt-3 ${fullWidth ? '' : 'xl:max-w-4xl 2xl:max-w-6xl'}`}>
|
||||
className={`px-5 pt-3 ${fullWidth ? '' : 'xl:max-w-4xl 2xl:max-w-6xl'}`}>
|
||||
{/* 文章信息 */}
|
||||
<ArticleInfo post={post} />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user