import CONFIG from './config' import { createContext, useContext, useEffect, useState } from 'react' import Header from './components/Nav' import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { BlogListPage } from './components/BlogListPage' import { BlogListScroll } from './components/BlogListScroll' import { isBrowser } from '@/lib/utils' import SearchNavBar from './components/SearchNavBar' 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 { ArticleFooter } from './components/ArticleFooter' import ShareBar from '@/components/ShareBar' import Link from 'next/link' import { Transition } from '@headlessui/react' import BottomNav from './components/BottomNav' import Modal from './components/Modal' import { Style } from './style' import replaceSearchResult from '@/components/Mark' import CommonHead from '@/components/CommonHead' // 主题全局状态 const ThemeGlobalPlog = createContext() export const usePlogGlobal = () => useContext(ThemeGlobalPlog) /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 * @returns {JSX.Element} * @constructor */ const LayoutBase = props => { const { children, topSlot, meta } = props const { onLoading } = useGlobal() const [showModal, setShowModal] = useState(false) const [modalContent, setModalContent] = useState(null) return ( {/* SEO相关 */} {/* 移动端顶部导航栏 */} {/* 主区 */} {/* 顶部插槽 */} {topSlot} {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 useEffect(() => { if (isBrowser) { replaceSearchResult({ doms: document.getElementById('posts-wrapper'), search: keyword, target: { element: 'span', className: 'text-red-500 border-b border-dashed' } }) } }, []) 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 } = props return ( {lock && } {!lock && <> > } ) } /** * 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, LayoutPostList, LayoutCategoryIndex, LayoutTagIndex }