import React, { useCallback, useEffect } from 'react' import { ArticleLock } from './components/ArticleLock' import HeaderArticle from './components/HeaderArticle' import LayoutBase from './LayoutBase' import Comment from '@/components/Comment' import NotionPage from '@/components/NotionPage' import ArticleAdjacent from './components/ArticleAdjacent' import ArticleCopyright from './components/ArticleCopyright' import { ArticleInfo } from './components/ArticleInfo' import Catalog from './components/Catalog' import JumpToCommentButton from './components/JumpToCommentButton' import throttle from 'lodash.throttle' export const LayoutSlug = props => { const { post, lock, validPassword } = props const [show, switchShow] = React.useState(false) const throttleMs = 200 const scrollListener = useCallback(throttle(() => { const scrollY = window.pageYOffset const shouldShow = scrollY > 220 && post?.toc?.length > 0 if (shouldShow !== show) { switchShow(shouldShow) } }, throttleMs)) useEffect(() => { document.addEventListener('scroll', scrollListener) return () => document.removeEventListener('scroll', scrollListener) }, []) if (!post) { return } {...props} showCategory={false} showTag={false} > } return (} {...props} showCategory={false} showTag={false} >
{lock && } {!lock &&
{post?.type && post?.type === 'Post' && <>

}
{/* Notion文章主体 */}
{post && }
{/* 文章内嵌广告 */}
{/* 文章版权说明 */} {post.type === 'Post' && }

{/* 评论互动 */}
}
{/* 文章推荐 */} {post.type === 'Post' && } {/* 文章目录 */} {post?.toc?.length > 0 &&
}
) }