import CONFIG from './config' import { BlogListPage } from './components/BlogListPage' import { BlogListScroll } from './components/BlogListScroll' import { useRouter } from 'next/router' import { useEffect } from 'react' import Mark from 'mark.js' import { isBrowser, loadExternalResource } from '@/lib/utils' import BlogArchiveItem from './components/BlogArchiveItem' import { ArticleLock } from './components/ArticleLock' import NotionPage from '@/components/NotionPage' import { ArticleInfo } from './components/ArticleInfo' import Comment from '@/components/Comment' import ArticleAround from './components/ArticleAround' import ShareBar from '@/components/ShareBar' import { AdSlot } from '@/components/GoogleAdsense' import Link from 'next/link' import CommonHead from '@/components/CommonHead' import { TopBar } from './components/TopBar' import { Header } from './components/Header' import { NavBar } from './components/NavBar' import BLOG from '@/blog.config' import { SideBar } from './components/SideBar' import JumpToTopButton from './components/JumpToTopButton' import { Footer } from './components/Footer' import { useGlobal } from '@/lib/global' import SearchInput from './components/SearchInput' import { Transition } from '@headlessui/react' /** * 基础布局 * * @param {*} props * @returns */ const LayoutBase = props => { const { children, meta, slotTop } = props const { onLoading } = useGlobal() if (isBrowser()) { loadExternalResource('/css/theme-simple.css', 'css') } return (
{CONFIG.TOP_BAR && } {/* 顶部LOGO */}
{/* 导航栏 */} {/* 主体 */}
{slotTop} {children}
) } /** * 博客首页 * 首页就是列表 * @param {*} props * @returns */ const LayoutIndex = props => { return } /** * 博客列表 * @param {*} props * @returns */ const LayoutPostList = props => { return ( {BLOG.POST_LIST_STYLE === 'page' ? : } ) } /** * 搜索页 * 也是博客列表 * @param {*} props * @returns */ const LayoutSearch = props => { const { keyword } = props const router = useRouter() useEffect(() => { setTimeout(() => { const container = isBrowser() && document.getElementById('posts-wrapper') if (container && container.innerHTML) { const re = new RegExp(keyword, 'gim') const instance = new Mark(container) instance.markRegExp(re, { element: 'span', className: 'text-red-500 border-b border-dashed' }) } }, 100) }, [router]) return } /> } /** * 归档页 * @param {*} props * @returns */ const LayoutArchive = props => { const { archivePosts } = props return (
{Object.keys(archivePosts).map(archiveTitle => )}
) } /** * 文章详情 * @param {*} props * @returns */ const LayoutSlug = props => { const { post, lock, validPassword, prev, next } = props return ( {lock && }
{/* 文章信息 */} {/* 广告嵌入 */} {/* Notion文章主体 */} {!lock && } {/* 分享 */} {/* 广告嵌入 */} {post?.type === 'Post' && } {/* 评论区 */}
) } /** * 404 * @param {*} props * @returns */ const Layout404 = (props) => { return 404 Not found. } /** * 分类列表 * @param {*} props * @returns */ const LayoutCategoryIndex = props => { const { categoryOptions } = props return (
{categoryOptions?.map(category => { return (
{category.name}({category.count})
) })}
) } /** * 标签列表 * @param {*} props * @returns */ const LayoutTagIndex = (props) => { const { tagOptions } = props return (
{tagOptions.map(tag => { return (
{tag.name + (tag.count ? `(${tag.count})` : '')}
) })}
) } export { CONFIG as THEME_CONFIG, LayoutIndex, LayoutSearch, LayoutArchive, LayoutSlug, Layout404, LayoutCategoryIndex, LayoutPostList, LayoutTagIndex }