'use client'
import CONFIG from './config'
import { useRouter } from 'next/router'
import { useEffect, useState, createContext, useContext } from 'react'
import { isBrowser } from '@/lib/utils'
import Footer from './components/Footer'
import InfoCard from './components/InfoCard'
import RevolverMaps from './components/RevolverMaps'
import TopNavBar from './components/TopNavBar'
import SearchInput from './components/SearchInput'
import { useGlobal } from '@/lib/global'
import Live2D from '@/components/Live2D'
import BLOG from '@/blog.config'
import NavPostList from './components/NavPostList'
import ArticleInfo from './components/ArticleInfo'
import Catalog from './components/Catalog'
import Announcement from './components/Announcement'
import PageNavDrawer from './components/PageNavDrawer'
import FloatTocButton from './components/FloatTocButton'
import { AdSlot } from '@/components/GoogleAdsense'
import JumpToTopButton from './components/JumpToTopButton'
import ShareBar from '@/components/ShareBar'
import CategoryItem from './components/CategoryItem'
import TagItemMini from './components/TagItemMini'
import ArticleAround from './components/ArticleAround'
import Comment from '@/components/Comment'
import TocDrawer from './components/TocDrawer'
import NotionPage from '@/components/NotionPage'
import { ArticleLock } from './components/ArticleLock'
import { Transition } from '@headlessui/react'
import { Style } from './style'
import CommonHead from '@/components/CommonHead'
import BlogArchiveItem from './components/BlogArchiveItem'
import BlogPostListAll from './components/BlogPostListAll'
import BlogPostListPage from './components/BlogPostListPage'
import BlogPostCard from './components/BlogPostCard'
import LogoBar from './components/LogoBar'
import Link from 'next/link'
import dynamic from 'next/dynamic'
const WWAds = dynamic(() => import('@/components/WWAds'), { ssr: false })
import { MenuItem } from './components/MenuItem'
// 主题全局变量
const ThemeGlobalNav = createContext()
export const useNavGlobal = () => useContext(ThemeGlobalNav)
/**
* 基础布局
* 采用左右两侧布局,移动端使用顶部导航栏
* @returns {JSX.Element}
* @constructor
*/
const LayoutBase = (props) => {
const { customMenu, children, post, allNavPages, categoryOptions, slotLeft, slotRight, slotTop, meta } = props
const { onLoading } = useGlobal()
const router = useRouter()
const [tocVisible, changeTocVisible] = useState(false)
const [pageNavVisible, changePageNavVisible] = useState(false)
const [filteredNavPages, setFilteredNavPages] = useState(allNavPages)
const showTocButton = post?.toc?.length > 1
useEffect(() => {
setFilteredNavPages(allNavPages)
}, [post])
let links = customMenu
// let categoryOptions = filteredNavPages
return (
{/*
*/}
{/* 顶部导航栏 */}
a
{/* 左侧图标Logo */}
{/* 左侧推拉抽屉 */}
{slotLeft}
{/* 所有文章列表 */}
{CONFIG.USE_CUSTEM_MENU && links && links?.map((link, index) =>
)}
{/* {!CONFIG.USE_CUSTEM_MENU &&
} */}
{/* {links && links?.map((link, index) => {
})} */}
{/* href={`/category/${category.name}`} */}
{!CONFIG.USE_CUSTEM_MENU && categoryOptions && categoryOptions?.map(category => {
// let selected = currentCategory === category.name
let selected = false;
return (
{category.name}({category.count})
)
})}
{slotTop}
{children}
{/* Google广告 */}
{/* 回顶按钮 */}
{/* 底部 */}
{/* 右侧侧推拉抽屉 */}
{/*
{slotRight}
{router.route === '/' && <>
{CONFIG.WIDGET_REVOLVER_MAPS === 'true' &&
}
>}*/}
{/* onenav主题首页只显示公告 */}
{/*
*/}
{/* 移动端悬浮目录按钮 */}
{showTocButton && !tocVisible &&
}
{/* 移动端导航抽屉 */}
{/* 移动端底部导航栏 */}
{/*
*/}
)
}
/**
* 首页
* @param {*} props
* @returns 此主题首页就是列表
*/
const LayoutIndex = props => {
return
}
/**
* 首页列表
* @param {*} props
* @returns
*/
const LayoutPostListIndex = props => {
// const { customMenu, children, post, allNavPages, categoryOptions, slotLeft, slotRight, slotTop, meta } = props
// const [filteredNavPages, setFilteredNavPages] = useState(allNavPages)
return (
)
}
/**
* 首页
* @param {*} props
* @returns 此主题首页就是列表
*/
const LayoutIndexNew = props => {
return
}
/**
* 文章列表
* @param {*} props
* @returns
*/
const LayoutPostList = props => {
const { posts, category, tag } = props
// 顶部如果是按照分类或标签查看文章列表,列表顶部嵌入一个横幅
// 如果是搜索,则列表顶部嵌入 搜索框
return (
{posts?.map(post => (
))}
)
}
/**
* 首页
* 重定向到某个文章详情页
* @param {*} props
* @returns
*/
const LayoutIndexCustemPage = (props) => {
const router = useRouter()
useEffect(() => {
router.push(CONFIG.INDEX_PAGE).then(() => {
// console.log('跳转到指定首页', CONFIG.INDEX_PAGE)
setTimeout(() => {
if (isBrowser) {
const article = document.getElementById('notion-article')
if (!article) {
console.log('请检查您的Notion数据库中是否包含此slug页面: ', CONFIG.INDEX_PAGE)
const containerInner = document.querySelector('#theme-onenav #container-inner')
const newHTML = `
配置有误
请在您的notion中添加一个slug为${CONFIG.INDEX_PAGE}的文章
`
containerInner?.insertAdjacentHTML('afterbegin', newHTML)
}
}
}, 7 * 1000)
})
}, [])
return
}
/**
* 文章列表 无
* 全靠页面导航
* @param {*} props
* @returns
*/
const LayoutPostListOld = (props) => {
return
}
/**
* 文章详情
* @param {*} props
* @returns
*/
const LayoutSlug = (props) => {
const { post, prev, next, lock, validPassword } = props
return (
{/* 文章锁 */}
{lock && }
{!lock &&
{/* title */}
{post?.title}
{/* Notion文章主体 */}
{post && (
{/* 分享 */}
{/* */}
{/* 文章分类和标签信息 */}
{CONFIG.POST_DETAIL_CATEGORY && post?.category &&
}
{CONFIG.POST_DETAIL_TAG && post?.tagItems?.map(tag => )}
{/* 上一篇、下一篇文章 */}
{/* {post?.type === 'Post' && } */}
)}
}
)
}
/**
* 没有搜索
* 全靠页面导航
* @param {*} props
* @returns
*/
const LayoutSearch = (props) => {
return
}
/**
* 归档页面基本不会用到
* 全靠页面导航
* @param {*} props
* @returns
*/
const LayoutArchive = (props) => {
const { archivePosts } = props
return
{Object.keys(archivePosts)?.map(archiveTitle => )}
}
/**
* 404
*/
const Layout404 = props => {
return
404 Not found.
}
/**
* 分类列表
*/
const LayoutCategoryIndex = (props) => {
const { categoryOptions } = props
const { locale } = useGlobal()
return
{locale.COMMON.CATEGORY}:
{categoryOptions?.map(category => {
return (
{category.name}({category.count})
)
})}
}
/**
* 标签列表
*/
const LayoutTagIndex = (props) => {
const { tagOptions } = props
const { locale } = useGlobal()
return
}
export {
CONFIG as THEME_CONFIG,
LayoutIndex,
LayoutSearch,
LayoutArchive,
LayoutSlug,
Layout404,
LayoutCategoryIndex,
LayoutPostList,
LayoutTagIndex
}