import CONFIG from './config' import { createContext, useContext, useEffect, useRef } from 'react' import { isBrowser } from '@/lib/utils' import { useGlobal } from '@/lib/global' import { AdSlot } from '@/components/GoogleAdsense' import { siteConfig } from '@/lib/config' import { Transition } from '@headlessui/react' import Link from 'next/link' import { Style } from './style' import replaceSearchResult from '@/components/Mark' import dynamic from 'next/dynamic' import NotionPage from '@/components/NotionPage' import AlgoliaSearchModal from '@/components/AlgoliaSearchModal' // 主题组件 const BlogListScroll = dynamic(() => import('./components/BlogListScroll'), { ssr: false }); const BlogArchiveItem = dynamic(() => import('./components/BlogArchiveItem'), { ssr: false }); const ArticleLock = dynamic(() => import('./components/ArticleLock'), { ssr: false }); const ArticleInfo = dynamic(() => import('./components/ArticleInfo'), { ssr: false }); const Comment = dynamic(() => import('@/components/Comment'), { ssr: false }); const ArticleAround = dynamic(() => import('./components/ArticleAround'), { ssr: false }); const ShareBar = dynamic(() => import('@/components/ShareBar'), { ssr: false }); const TopBar = dynamic(() => import('./components/TopBar'), { ssr: false }); const Header = dynamic(() => import('./components/Header'), { ssr: false }); const NavBar = dynamic(() => import('./components/NavBar'), { ssr: false }); const SideBar = dynamic(() => import('./components/SideBar'), { ssr: false }); 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 CommonHead = dynamic(() => import('@/components/CommonHead'), { ssr: false }); const WWAds = dynamic(() => import('@/components/WWAds'), { ssr: false }); const BlogListPage = dynamic(() => import('./components/BlogListPage'), { ssr: false }) // 主题全局状态 const ThemeGlobalSimple = createContext() export const useSimpleGlobal = () => useContext(ThemeGlobalSimple) /** * 基础布局 * * @param {*} props * @returns */ const LayoutBase = props => { const { children, slotTop, meta } = props const { onLoading, fullWidth } = useGlobal() const searchModal = useRef(null) return ( {/* SEO相关 */} {siteConfig('SIMPLE_TOP_BAR', null, CONFIG) && } {/* 顶部LOGO */} {/* 导航栏 */} {/* 主体 */} {slotTop} {children} {fullWidth ? null : } {/* 搜索框 */} ) } /** * 博客首页 * 首页就是列表 * @param {*} props * @returns */ const LayoutIndex = props => { return } /** * 博客列表 * @param {*} props * @returns */ const LayoutPostList = props => { return ( {siteConfig('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' } }) } }, []) const slotTop = siteConfig('ALGOLIA_APP_ID') ? null : 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 const { fullWidth } = useGlobal() 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 }