import BLOG from '@/blog.config' import { useRouter } from 'next/router' import Progress from '@/components/Progress' import TagItem from '@/components/TagItem' import formatDate from '@/lib/formatDate' import { Code, Collection, CollectionRow, Equation, NotionRenderer } from 'react-notion-x' import ShareBar from '@/components/ShareBar' import Comment from '@/components/Comment' import Link from 'next/link' import Image from 'next/image' import 'prismjs' import 'prismjs/components/prism-bash' import 'prismjs/components/prism-markup' import 'prismjs/components/prism-python' import 'prismjs/components/prism-javascript' import 'prismjs/components/prism-typescript' import RecommendPosts from '@/components/RecommendPosts' import TocDrawer from '@/components/TocDrawer' import TocDrawerButton from '@/components/TocDrawerButton' import { useGlobal } from '@/lib/global' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faEye, faFolderOpen } from '@fortawesome/free-solid-svg-icons' import BlogAround from '@/components/BlogAround' import { useEffect, useRef } from 'react' /** * * @param {*} param0 * @returns */ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, next }) { const targetRef = useRef(null) const drawerRight = useRef(null) const url = BLOG.link + useRouter().asPath const { locale } = useGlobal() const date = formatDate(post?.date?.start_date || post.createdTime, BLOG.lang) useEffect(() => { countWords() }) return (<>
{post.type && !post.type.includes('Page') && post?.page_cover && (
{post.title}
)} {/* 文章Title */}

{' '} {post.title}


{post.category} {post.type[0] !== 'Page' && ( {date} )}
 
{post.summary}
本文共0字,阅读需要约0分钟
{/* Notion文章主体 */}
{blockMap && ( )}
{/* 文章内嵌广告 */}
{/* 推荐文章 */} {/* 版权声明 */}
版权声明
  • 本文作者:{' '} {BLOG.author}
  • 本文链接:{' '} {url}
  • 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
{/* 标签列表 */}
{post.tagItems && (
{locale.COMMON.TAGS}:
{post.tagItems.map(tag => ( ))}
)}
{/* 评论互动 */}
{/* 悬浮目录按钮 */}
{ drawerRight.current.handleSwitchVisible() }} />
) } const mapPageUrl = id => { return 'https://www.notion.so/' + id.replace(/-/g, '') } /** * 更新字数统计和阅读时间 */ function countWords () { if (window) { const articleElement = document.getElementById('notion-article') if (articleElement) { const articleText = deleteHtmlTag(articleElement.innerHTML) const wordCount = fnGetCpmisWords(articleText) // 阅读速度 300-500每分钟 document.getElementById('wordCount').innerHTML = wordCount document.getElementById('readTime').innerHTML = Math.floor(wordCount / 400) } } } // 去除html标签 function deleteHtmlTag (str) { str = str.replace(/<[^>]+>|&[^>]+;/g, '').trim()// 去掉所有的html标签和 之类的特殊符合 return str } // 用word方式计算正文字数 function fnGetCpmisWords (str) { let sLen = 0 try { // eslint-disable-next-line no-irregular-whitespace str = str.replace(/(\r\n+|\s+| +)/g, '龘') // eslint-disable-next-line no-control-regex str = str.replace(/[\x00-\xff]/g, 'm') str = str.replace(/m+/g, '*') str = str.replace(/龘+/g, '') sLen = str.length } catch (e) { } return sLen }