diff --git a/.env.local b/.env.local index ce96b790..fed79673 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=3.6.4 \ No newline at end of file +NEXT_PUBLIC_VERSION=3.6.7 \ No newline at end of file diff --git a/README.md b/README.md index 24b65760..495a7042 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # NotionNext -一个使用 NextJS + Notion API 实现的,部署在 Vercel 上的静态博客系统。为Notion和所有创作者设计。 -

@@ -17,74 +15,20 @@

-演示地址:[https://preview.tangly1024.com/](https://preview.tangly1024.com/) +一个使用 NextJS + Notion API 实现的,部署在 Vercel 上的静态博客系统。为Notion和所有创作者设计。 -## 继承自Nobelium的亮点 ✨ -**🚀  秒开,设备全适配** +## 预览效果 -- 快速的页面渲染和响应式设计 -- 高效编译器的快速静态页面生成 - -**🤖  自动,无需重新部署** - -- 部署在免费、高速的 Vercel 平台 -- 支持增量式更新,更新文章后无需重复部署 - -**🚙  全功能,完全不操心** - -- 评论、搜索、标签、分类 -- 订阅、网站统计 -- 本地化多语言 -- 服务端渲染、优秀的SEO - -**🎨  美观,轻松自定义** -- 丰富的配置项,更支持多语言 -- 使用 Tailwind CSS,轻松实现二次开发 - -## 特色 -- 支持更多的页面,功能,更多特性、欢迎移步[我的博客](https://tangly1024.com/article/notion-next)查看 -- 支持多主题切换 +在线演示:[https://preview.tangly1024.com/](https://preview.tangly1024.com/) ,项目支持多主题切换,没找到喜欢的主题?[贡献](/CONTRIBUTING.md)一个吧~ | Next | Medium | Hexo | Fukasawa | |--|--|--|--| | [预览NEXT](https://preview.tangly1024.com/?theme=next) | [预览MEDIUM](https://preview.tangly1024.com/?theme=medium) | [预览HEXO](https://preview.tangly1024.com/?theme=hexo) | [预览FUKASAWA](https://preview.tangly1024.com/?theme=fukasawa) | -*只需修改`blog.config.js`文件的`THEME`即可实现主题切换。* 没找到喜欢的主题?[贡献](/CONTRIBUTING.md)一个吧~ +## 我要如何开始? - - -## 快速起步 - -- 给这个项目点个小星星 😉 -- 将 [这个 Notion 模板](https://tanghh.notion.site/02ab3b8678004aa69e9e415905ef32a5) 制作副本,并分享这个页面给所有人 -- [Fork](https://github.com/tangly1024/NotionNext/fork) 这个项目 - - _(可选)_ 用自己的图片替换 `/public` 文件夹里的 `avatar.jpg`、`favicon.svg` 和 `favicon.ico` - - 在 `blog.config.js` 配置相关选项,`NOTION_PAGE_ID`: 你刚刚分享出去的 Notion 页面网址中的页面 ID,通常是网址中工作区地址后的 32 位字符串 -- 在 [Vercel](https://vercel.com)中部署项目 -- **稍微等等就可以访问了!** 简单吗? - -更多项目特性及配置的说明,请移步 [NotionNext文档](https://docs.tangly1024.com/zh) 查看,文档正在完善中,欢迎 [参与编辑](https://github.com/tangly1024/nextjs-docs-notion-next) - -## 快速开发 -- 需要安装Nodejs环境 -```bash -yarn # 安装依赖 -yarn run dev # 本地开发 -yarn run build # 本地打包编译 -yarn run start # 本地启动NextJS服务 -``` - -## 引用技术 - -- **框架**: [Next.js](https://nextjs.org) -- **样式**: [Tailwind CSS](https://www.tailwindcss.cn/) 和 `@tailwindcss/jit` compiler -- **渲染**: [React-notion-x](https://github.com/NotionX/react-notion-x) -- **评论**: [Giscus](https://giscus.app/zh-CN), [Gitalk](https://gitalk.github.io), [Cusdis](https://cusdis.com), [Utterances](https://utteranc.es) -- **图标**:[fontawesome v5.15](https://fontawesome.com/v5.15/icons?d=gallery) - -## 更新日志 -请移步 [更新文档](https://docs.tangly1024.com/zh/changelog)查看 +只需几分钟即可搭建您的个人站点,欢迎移步[我的博客](https://tangly1024.com/article/notion-next) 查看教程 ## 致谢 @@ -120,12 +64,17 @@ yarn run start # 本地启动NextJS服务 SwwweetOrange
SwwweetOrange

🔧 🐛 Ylarod
Ylarod

🔧 🐛 -v -十分期待你的[贡献](/CONTRIBUTING.md),一起来完善这个项目~ +## 引用技术 + +- **框架**: [Next.js](https://nextjs.org) +- **样式**: [Tailwind CSS](https://www.tailwindcss.cn/) 和 `@tailwindcss/jit` compiler +- **渲染**: [React-notion-x](https://github.com/NotionX/react-notion-x) +- **评论**: [Giscus](https://giscus.app/zh-CN), [Gitalk](https://gitalk.github.io), [Cusdis](https://cusdis.com), [Utterances](https://utteranc.es) +- **图标**: [Fontawesome](https://fontawesome.com/v6/icons/) ## License diff --git a/components/CommonHead.js b/components/CommonHead.js index de4c7d25..5938dc6d 100644 --- a/components/CommonHead.js +++ b/components/CommonHead.js @@ -43,6 +43,12 @@ const CommonHead = ({ meta, children }) => { + + { BLOG.CUSTOM_FONT + ? BLOG.CUSTOM_FONT_URL?.map(fontUrl => + ) + : } + {JSON.parse(BLOG.ANALYTICS_BUSUANZI_ENABLE) && } {meta?.type === 'Post' && ( <> diff --git a/components/PrismMac.js b/components/PrismMac.js index 22fc3709..956e9f73 100644 --- a/components/PrismMac.js +++ b/components/PrismMac.js @@ -8,7 +8,6 @@ import 'prismjs/plugins/line-numbers/prism-line-numbers.css' // 所有语言的prismjs 使用autoloader引入 import 'prismjs/plugins/autoloader/prism-autoloader' // mermaid图 -import mermaid from 'mermaid' import BLOG from '@/blog.config' /** @@ -18,6 +17,7 @@ import BLOG from '@/blog.config' const PrismMac = () => { React.useEffect(() => { renderPrismMac() + renderMermaid() // 折叠代码行号bug const observer = new MutationObserver(mutationsList => { @@ -35,21 +35,10 @@ const PrismMac = () => { return <> } -function renderPrismMac() { - const container = document?.getElementById('container-inner') - const codeToolBars = container?.getElementsByClassName('code-toolbar') - - // Add line numbers - const codeBlocks = container?.getElementsByTagName('pre') - if (codeBlocks) { - Array.from(codeBlocks).forEach(item => { - if (!item.classList.contains('line-numbers')) { - item.classList.add('line-numbers') - item.style.whiteSpace = 'pre-wrap' - } - }) - } - +/** + * 将mermaid语言 渲染成图片 + */ +const renderMermaid = async() => { // 支持 Mermaid const mermaidPres = document.querySelectorAll('pre.notion-code.language-mermaid') if (mermaidPres) { @@ -73,9 +62,26 @@ function renderPrismMac() { } } if (needLoad) { - mermaid.contentLoaded() + const asyncMermaid = await import('mermaid') + asyncMermaid.default.contentLoaded() } } +} + +function renderPrismMac() { + const container = document?.getElementById('container-inner') + const codeToolBars = container?.getElementsByClassName('code-toolbar') + + // Add line numbers + const codeBlocks = container?.getElementsByTagName('pre') + if (codeBlocks) { + Array.from(codeBlocks).forEach(item => { + if (!item.classList.contains('line-numbers')) { + item.classList.add('line-numbers') + item.style.whiteSpace = 'pre-wrap' + } + }) + } // 重新渲染之前检查所有的多余text diff --git a/lib/busuanzi.js b/lib/busuanzi.js index 9255485a..439aa4b7 100644 --- a/lib/busuanzi.js +++ b/lib/busuanzi.js @@ -94,11 +94,6 @@ bszTag = { } } -// 修复Node同构代码的问题 -if (typeof document !== 'undefined') { - fetch() -} - module.exports = { fetch } diff --git a/lib/font.js b/lib/font.js index d485eebd..05ba86ff 100644 --- a/lib/font.js +++ b/lib/font.js @@ -50,4 +50,4 @@ const fontFamilies = { ] } -module.exports = fontFamilies +module.exports = { fontFamilies } diff --git a/lib/notion/getAllCategories.js b/lib/notion/getAllCategories.js index 2225b965..b7700bc1 100644 --- a/lib/notion/getAllCategories.js +++ b/lib/notion/getAllCategories.js @@ -14,7 +14,7 @@ import { isIterable } from '../utils' * @returns {Promise<{}|*[]>} */ export function getAllCategories({ allPages, categoryOptions, sliceCount = 0 }) { - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') if (!allPosts || !categoryOptions) { return [] } diff --git a/lib/notion/getAllTags.js b/lib/notion/getAllTags.js index 098f62fb..b9144be8 100644 --- a/lib/notion/getAllTags.js +++ b/lib/notion/getAllTags.js @@ -8,7 +8,7 @@ import { isIterable } from '../utils' * @returns {Promise<{}|*[]>} */ export function getAllTags({ allPages, sliceCount = 0, tagOptions }) { - const allPosts = allPages.filter(page => page.type === 'Post') + const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published') if (!allPosts || !tagOptions) { return [] diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 11913b2d..80444cdb 100644 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -212,17 +212,16 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { collectionData.push(properties) } } - // 读取映射 配置 - let postCount = 0 // 获取page作为自定义菜单 const customNav = getCustomNav({ allPages: collectionData.filter(post => post.type === 'Page' && post.status === 'Published') }) + // 文章计数 + let postCount = 0 const allPages = collectionData.filter(post => { if (post.type === 'Post' && post.status === 'Published') { postCount++ } - return post && post.type && (post.type === 'Post' || post.type === 'Page') && diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js index f4ee3282..ef93f84b 100644 --- a/lib/notion/getPageProperties.js +++ b/lib/notion/getPageProperties.js @@ -3,6 +3,7 @@ import { NotionAPI } from 'notion-client' import BLOG from '@/blog.config' import formatDate from '../formatDate' import { defaultMapImageUrl } from 'react-notion-x' +import md5 from 'js-md5' export default async function getPageProperties(id, block, schema, authToken, tagOptions, siteInfo) { const rawProperties = Object.entries(block?.[id]?.value?.properties || []) @@ -89,6 +90,7 @@ export default async function getPageProperties(id, block, schema, authToken, ta properties.pageIcon = getImageUrl(block[id].value?.format?.page_icon, block[id].value) ?? '' properties.page_cover = getImageUrl(block[id].value?.format?.page_cover, block[id].value) ?? siteInfo?.pageCover properties.content = value.content ?? [] + properties.password = properties.password ? md5(properties.slug + properties.password) : '' properties.tagItems = properties?.tags?.map(tag => { return { name: tag, color: tagOptions?.find(t => t.value === tag)?.color || 'gray' } }) || [] diff --git a/lib/notion/getPageTableOfContents.js b/lib/notion/getPageTableOfContents.js new file mode 100644 index 00000000..a23be7cb --- /dev/null +++ b/lib/notion/getPageTableOfContents.js @@ -0,0 +1,90 @@ +import { getTextContent } from 'notion-utils' + +const indentLevels = { + header: 0, + sub_header: 1, + sub_sub_header: 2 +} + +/** + * @see https://github.com/NotionX/react-notion-x/blob/master/packages/notion-utils/src/get-page-table-of-contents.ts + * Gets the metadata for a table of contents block by parsing the page's + * H1, H2, and H3 elements. + */ +export const getPageTableOfContents = (page, recordMap) => { + const contents = (page.content ?? []) + const toc = getBlockHeader(contents, recordMap) + const indentLevelStack = [ + { + actual: -1, + effective: -1 + } + ] + + // Adjust indent levels to always change smoothly. + // This is a little tricky, but the key is that when increasing indent levels, + // they should never jump more than one at a time. + for (const tocItem of toc) { + const { indentLevel } = tocItem + const actual = indentLevel + + do { + const prevIndent = indentLevelStack[indentLevelStack.length - 1] + const { actual: prevActual, effective: prevEffective } = prevIndent + + if (actual > prevActual) { + tocItem.indentLevel = prevEffective + 1 + indentLevelStack.push({ + actual, + effective: tocItem.indentLevel + }) + } else if (actual === prevActual) { + tocItem.indentLevel = prevEffective + break + } else { + indentLevelStack.pop() + } + + // eslint-disable-next-line no-constant-condition + } while (true) + } + + return toc +} + +/** + * 重写获取目录方法 + */ +function getBlockHeader(contents, recordMap, toc) { + if (!toc) { + toc = [] + } + if (!contents) { + return toc + } + + for (const blockId of contents) { + const block = recordMap.block[blockId]?.value + if (!block) { + continue + } + const { type } = block + if (type.indexOf('header') >= 0) { + const existed = toc.find(e => e.id === blockId) + if (!existed) { + toc.push({ + id: blockId, + type, + text: getTextContent(block.properties?.title), + indentLevel: indentLevels[type] + }) + } + } + + if (block.content?.length > 0) { + getBlockHeader(block.content, recordMap, toc) + } + } + + return toc +} diff --git a/package.json b/package.json index 6eb4edad..c1a01253 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "3.6.4", + "version": "3.6.7", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": { @@ -30,6 +30,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "feed": "^4.2.2", "gitalk": "^1.7.2", + "js-md5": "^0.7.3", "localStorage": "^1.0.4", "lodash.throttle": "^4.1.1", "mark.js": "^8.11.1", diff --git a/pages/[...slug].js b/pages/[...slug].js index c790f211..6ca98c93 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -8,6 +8,8 @@ import { idToUuid } from 'notion-utils' import Router from 'next/router' import { isBrowser } from '@/lib/utils' import { getNotion } from '@/lib/notion/getNotion' +import md5 from 'js-md5' +import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents' /** * 根据notion的slug访问页面 @@ -28,6 +30,11 @@ const Slug = props => { if (post?.password && post?.password !== '') { setLock(true) } else { + if (!lock && post?.blockMap?.block) { + post.content = Object.keys(post.blockMap.block) + post.toc = getPageTableOfContents(post, post.blockMap) + } + setLock(false) } }, [post]) @@ -51,10 +58,12 @@ const Slug = props => { * 验证文章密码 * @param {*} result */ - const validPassword = result => { - if (result) { + const validPassword = passInput => { + if (passInput && md5(post.slug + passInput) === post.password) { setLock(false) + return true } + return false } props = { ...props, lock, setLock, validPassword } diff --git a/pages/_app.js b/pages/_app.js index 9a3969a3..200a6b43 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -23,6 +23,8 @@ import { GlobalContextProvider } from '@/lib/global' import { DebugPanel } from '@/components/DebugPanel' import { ThemeSwitch } from '@/components/ThemeSwitch' import { Fireworks } from '@/components/Fireworks' +import React from 'react' +import { loadExternalResource } from '@/lib/utils' const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false }) const Gtag = dynamic(() => import('@/components/Gtag'), { ssr: false }) @@ -47,10 +49,13 @@ const MyApp = ({ Component, pageProps }) => { {JSON.parse(BLOG.FIREWORKS) && } + // 延迟加载fontAwesome + React.useEffect(() => { + loadExternalResource(BLOG.FONT_AWESOME_PATH, 'css') + }, []) + return ( - {/* FontawesomeCDN */} - {externalPlugins} diff --git a/pages/_document.js b/pages/_document.js index 7aae613a..4438697e 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -15,10 +15,6 @@ class MyDocument extends Document { - { BLOG.CUSTOM_FONT - ? BLOG.CUSTOM_FONT_URL?.map(fontUrl => - ) - : } diff --git a/styles/globals.css b/styles/globals.css index a4e86ff1..f2f180e8 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -132,11 +132,6 @@ nav { backdrop-filter: blur(10px); } -.dark .glassmorphism { - background: rgba(31, 41, 55, 0.75); - -webkit-backdrop-filter: blur(10px); - backdrop-filter: blur(10px); -} .medium-zoom-overlay { background: none !important; diff --git a/styles/notion.css b/styles/notion.css index 92acdb96..d55d8456 100644 --- a/styles/notion.css +++ b/styles/notion.css @@ -392,7 +392,7 @@ .notion-h { position: relative; - display: block; + /* display: block; */ font-weight: 600; line-height: 1.3; padding: 3px 2px; @@ -427,7 +427,7 @@ margin-top: 2px; } */ .notion-h2 { - font-size: 1.5em; + font-size: 1.4em; margin-top: 1.1em; } .notion-h3 { diff --git a/tailwind.config.js b/tailwind.config.js index 829bee9f..5079e173 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,5 +1,5 @@ const BLOG = require('./blog.config') -const fontFamilies = require('./lib/font') +const { fontFamilies } = require('./lib/font') module.exports = { purge: ['./pages/**/*.js', './components/**/*.js', './layouts/**/*.js', './themes/**/*.js'], diff --git a/themes/example/LayoutSlug.js b/themes/example/LayoutSlug.js index 1f7fd409..b16892b7 100644 --- a/themes/example/LayoutSlug.js +++ b/themes/example/LayoutSlug.js @@ -1,4 +1,3 @@ -import { getPageTableOfContents } from 'notion-utils' import LayoutBase from './LayoutBase' import { ArticleLock } from './components/ArticleLock' import NotionPage from '@/components/NotionPage' @@ -12,15 +11,10 @@ export const LayoutSlug = props => { return } - if (!lock && post?.blockMap?.block) { - post.content = Object.keys(post.blockMap.block) - post.toc = getPageTableOfContents(post, post.blockMap) - } - return ( - {lock && } + {lock && } {!lock &&
diff --git a/themes/example/components/ArticleLock.js b/themes/example/components/ArticleLock.js index a9f5f59d..43b6647e 100644 --- a/themes/example/components/ArticleLock.js +++ b/themes/example/components/ArticleLock.js @@ -8,14 +8,12 @@ import { useGlobal } from '@/lib/global' * @returns */ export const ArticleLock = props => { - const { password, validPassword } = props + const { validPassword } = props const { locale } = useGlobal() const submitPassword = () => { const p = document.getElementById('password') - if (p && p.value && p.value === password) { - validPassword(true) - } else { + if (!validPassword(p?.value)) { const tips = document.getElementById('tips') if (tips) { tips.innerHTML = '' diff --git a/themes/example/components/ExampleRecentComments.js b/themes/example/components/ExampleRecentComments.js index 32d11463..e1fe86ca 100644 --- a/themes/example/components/ExampleRecentComments.js +++ b/themes/example/components/ExampleRecentComments.js @@ -1,7 +1,7 @@ import React from 'react' -import { RecentComments } from '@waline/client' import BLOG from '@/blog.config' import Link from 'next/link' +import { RecentComments } from '@waline/client' /** * @see https://waline.js.org/guide/get-started.html diff --git a/themes/example/components/SideBar.js b/themes/example/components/SideBar.js index 0e737fa3..ea45f851 100644 --- a/themes/example/components/SideBar.js +++ b/themes/example/components/SideBar.js @@ -2,7 +2,8 @@ import BLOG from '@/blog.config' import Live2D from '@/components/Live2D' import { useGlobal } from '@/lib/global' import Link from 'next/link' -import ExampleRecentComments from './ExampleRecentComments' +import dynamic from 'next/dynamic' +const ExampleRecentComments = dynamic(() => import('./ExampleRecentComments')) export const SideBar = (props) => { const { locale } = useGlobal() diff --git a/themes/fukasawa/LayoutSlug.js b/themes/fukasawa/LayoutSlug.js index 30265a6c..fb78690c 100644 --- a/themes/fukasawa/LayoutSlug.js +++ b/themes/fukasawa/LayoutSlug.js @@ -1,19 +1,13 @@ -import { getPageTableOfContents } from 'notion-utils' import ArticleDetail from './components/ArticleDetail' import LayoutBase from './LayoutBase' import { ArticleLock } from './components/ArticleLock' export const LayoutSlug = (props) => { - const { post, lock, validPassword } = props - if (!lock && post?.blockMap?.block) { - post.content = Object.keys(post.blockMap.block) - post.toc = getPageTableOfContents(post, post.blockMap) - } - + const { lock, validPassword } = props return ( {!lock && } - {lock && } + {lock && } ) } diff --git a/themes/fukasawa/components/ArticleLock.js b/themes/fukasawa/components/ArticleLock.js index 23112eeb..8ae18a4e 100644 --- a/themes/fukasawa/components/ArticleLock.js +++ b/themes/fukasawa/components/ArticleLock.js @@ -8,14 +8,12 @@ import { useGlobal } from '@/lib/global' * @returns */ export const ArticleLock = props => { - const { password, validPassword } = props + const { validPassword } = props const { locale } = useGlobal() const submitPassword = () => { const p = document.getElementById('password') - if (p && p.value && p.value === password) { - validPassword(true) - } else { + if (!validPassword(p?.value)) { const tips = document.getElementById('tips') if (tips) { tips.innerHTML = '' diff --git a/themes/hexo/LayoutArchive.js b/themes/hexo/LayoutArchive.js index 5f30f76e..8d2a1c08 100644 --- a/themes/hexo/LayoutArchive.js +++ b/themes/hexo/LayoutArchive.js @@ -39,7 +39,7 @@ export const LayoutArchive = (props) => { }, []) return -
+
{Object.keys(archivePosts).map(archiveTitle => ( { const { post, lock, validPassword } = props + const drawerRight = useRef(null) if (!post) { return { > } - if (!lock && post?.blockMap?.block) { - post.content = Object.keys(post.blockMap.block) - post.toc = getPageTableOfContents(post, post.blockMap) - } - - const drawerRight = useRef(null) const targetRef = isBrowser() ? document.getElementById('container') : null const floatSlot = <> @@ -53,7 +47,7 @@ export const LayoutSlug = props => { floatSlot={floatSlot} >
- {lock && } + {lock && } {!lock &&
diff --git a/themes/hexo/components/ArticleLock.js b/themes/hexo/components/ArticleLock.js index 84ef905f..1a1bd193 100644 --- a/themes/hexo/components/ArticleLock.js +++ b/themes/hexo/components/ArticleLock.js @@ -8,13 +8,11 @@ import { useGlobal } from '@/lib/global' * @returns */ export const ArticleLock = props => { - const { password, validPassword } = props + const { validPassword } = props const { locale } = useGlobal() const submitPassword = () => { const p = document.getElementById('password') - if (p && p.value && p.value === password) { - validPassword(true) - } else { + if (!validPassword(p?.value)) { const tips = document.getElementById('tips') if (tips) { tips.innerHTML = '' diff --git a/themes/hexo/components/HeaderArticle.js b/themes/hexo/components/HeaderArticle.js index 918c75c7..8ebfe2bd 100644 --- a/themes/hexo/components/HeaderArticle.js +++ b/themes/hexo/components/HeaderArticle.js @@ -4,12 +4,13 @@ import formatDate from '@/lib/formatDate' import BLOG from '@/blog.config' export default function HeaderArticle({ post, siteInfo }) { + const { locale } = useGlobal() + if (!post) { return <> } const headerImage = post?.page_cover ? `url("${post.page_cover}")` : `url("${siteInfo?.pageCover}")` - const { locale } = useGlobal() const date = formatDate( post?.date?.start_date || post?.createdTime, locale.LOCALE diff --git a/themes/hexo/components/HexoRecentComments.js b/themes/hexo/components/HexoRecentComments.js index 4977ccf4..d4cbacab 100644 --- a/themes/hexo/components/HexoRecentComments.js +++ b/themes/hexo/components/HexoRecentComments.js @@ -1,9 +1,9 @@ import React from 'react' -import { RecentComments } from '@waline/client' import BLOG from '@/blog.config' import Card from '@/themes/hexo/components/Card' import { useGlobal } from '@/lib/global' import Link from 'next/link' +import { RecentComments } from '@waline/client' /** * @see https://waline.js.org/guide/get-started.html diff --git a/themes/hexo/components/InfoCard.js b/themes/hexo/components/InfoCard.js index 3b28d0fa..1393211a 100644 --- a/themes/hexo/components/InfoCard.js +++ b/themes/hexo/components/InfoCard.js @@ -14,7 +14,7 @@ export function InfoCard (props) { }} > {/* eslint-disable-next-line @next/next/no-img-element */} - + {BLOG.AUTHOR}/
{BLOG.AUTHOR}
{BLOG.BIO}
diff --git a/themes/hexo/components/NavButtonGroup.js b/themes/hexo/components/NavButtonGroup.js index 7a71ee02..f15b992d 100644 --- a/themes/hexo/components/NavButtonGroup.js +++ b/themes/hexo/components/NavButtonGroup.js @@ -16,7 +16,7 @@ const NavButtonGroup = (props) => { return diff --git a/themes/hexo/components/SideRight.js b/themes/hexo/components/SideRight.js index 8079fb2d..8680f144 100644 --- a/themes/hexo/components/SideRight.js +++ b/themes/hexo/components/SideRight.js @@ -6,9 +6,10 @@ import Catalog from './Catalog' import { InfoCard } from './InfoCard' import { AnalyticsCard } from './AnalyticsCard' import CONFIG_HEXO from '../config_hexo' -import HexoRecentComments from './HexoRecentComments' import BLOG from '@/blog.config' +import dynamic from 'next/dynamic' +const HexoRecentComments = dynamic(() => import('./HexoRecentComments')) /** * Hexo主题右侧栏 * @param {*} props diff --git a/themes/medium/LayoutCategory.js b/themes/medium/LayoutCategory.js index a3018144..7522e264 100644 --- a/themes/medium/LayoutCategory.js +++ b/themes/medium/LayoutCategory.js @@ -5,7 +5,7 @@ import BLOG from '@/blog.config' export const LayoutCategory = props => { const { category } = props - const slotTop =
分类:
{category}
+ const slotTop =
分类:
{category}
return {BLOG.POST_LIST_STYLE === 'page' ? : } diff --git a/themes/medium/LayoutSlug.js b/themes/medium/LayoutSlug.js index f7fdc4d0..bdeec1a5 100644 --- a/themes/medium/LayoutSlug.js +++ b/themes/medium/LayoutSlug.js @@ -1,5 +1,3 @@ -import { getPageTableOfContents } from 'notion-utils' - import LayoutBase from './LayoutBase' import { useGlobal } from '@/lib/global' import React from 'react' @@ -16,11 +14,6 @@ export const LayoutSlug = props => { /> } - if (!lock && post?.blockMap?.block) { - post.content = Object.keys(post.blockMap.block) - post.toc = getPageTableOfContents(post, post.blockMap) - } - const slotRight = post?.toc && post?.toc?.length > 3 && (
@@ -29,7 +22,7 @@ export const LayoutSlug = props => { return ( - {!lock ? : } + {!lock ? : } ) } diff --git a/themes/medium/LayoutTag.js b/themes/medium/LayoutTag.js index 6f072aa9..41164ce3 100644 --- a/themes/medium/LayoutTag.js +++ b/themes/medium/LayoutTag.js @@ -5,7 +5,7 @@ import BlogPostListPage from './components/BlogPostListPage' export const LayoutTag = (props) => { const { tag } = props - const slotTop =
标签:
{tag}
+ const slotTop =
标签:
{tag}
return {BLOG.POST_LIST_STYLE === 'page' ? : } diff --git a/themes/medium/components/ArticleDetail.js b/themes/medium/components/ArticleDetail.js index 1fffc2a0..660cc1e1 100644 --- a/themes/medium/components/ArticleDetail.js +++ b/themes/medium/components/ArticleDetail.js @@ -36,7 +36,7 @@ export const ArticleDetail = props => {
{/* eslint-disable-next-line @next/next/no-img-element */} - + {BLOG.AUTHOR}
{BLOG.AUTHOR} diff --git a/themes/medium/components/ArticleLock.js b/themes/medium/components/ArticleLock.js index 4b969835..1e1bb228 100644 --- a/themes/medium/components/ArticleLock.js +++ b/themes/medium/components/ArticleLock.js @@ -8,14 +8,12 @@ import { useGlobal } from '@/lib/global' * @returns */ export const ArticleLock = props => { - const { password, validPassword } = props + const { validPassword } = props const { locale } = useGlobal() const submitPassword = () => { const p = document.getElementById('password') - if (p && p.value && p.value === password) { - validPassword(true) - } else { + if (!validPassword(p?.value)) { const tips = document.getElementById('tips') if (tips) { tips.innerHTML = '' diff --git a/themes/medium/components/InfoCard.js b/themes/medium/components/InfoCard.js index ce3f7bc3..f34b2ee6 100644 --- a/themes/medium/components/InfoCard.js +++ b/themes/medium/components/InfoCard.js @@ -9,7 +9,7 @@ const InfoCard = (props) => {
{ Router.push('/about') }}> {/* eslint-disable-next-line @next/next/no-img-element */} - + {BLOG.AUTHOR}/
{BLOG.AUTHOR}
{BLOG.BIO}
diff --git a/themes/next/LayoutArchive.js b/themes/next/LayoutArchive.js index ce66e25f..3db36dbd 100644 --- a/themes/next/LayoutArchive.js +++ b/themes/next/LayoutArchive.js @@ -39,7 +39,7 @@ export const LayoutArchive = (props) => { return ( -
+
{Object.keys(archivePosts).map(archiveTitle => ( { const { allPosts, categories } = props const { locale } = useGlobal() return -
+
{locale.COMMON.CATEGORY}:
diff --git a/themes/next/LayoutSlug.js b/themes/next/LayoutSlug.js index aa1cc4d2..fa1915a1 100644 --- a/themes/next/LayoutSlug.js +++ b/themes/next/LayoutSlug.js @@ -1,4 +1,3 @@ -import { getPageTableOfContents } from 'notion-utils' import TocDrawerButton from './components/TocDrawerButton' import LayoutBase from './LayoutBase' import Card from './components/Card' @@ -12,11 +11,6 @@ import { isBrowser } from '@/lib/utils' export const LayoutSlug = (props) => { const { post, latestPosts, lock, validPassword } = props - if (!lock && post?.blockMap?.block) { - post.content = Object.keys(post.blockMap.block) - post.toc = getPageTableOfContents(post, post.blockMap) - } - const drawerRight = useRef(null) const targetRef = isBrowser() ? document.getElementById('container') : null const floatSlot = post?.toc?.length > 1 @@ -45,7 +39,7 @@ export const LayoutSlug = (props) => { {!lock && } - {lock && } + {lock && } {/* 悬浮目录按钮 */}
diff --git a/themes/next/LayoutTagIndex.js b/themes/next/LayoutTagIndex.js index d7fae64e..45100a9e 100644 --- a/themes/next/LayoutTagIndex.js +++ b/themes/next/LayoutTagIndex.js @@ -6,7 +6,7 @@ export const LayoutTagIndex = (props) => { const { tags } = props const { locale } = useGlobal() return -
+
{locale.COMMON.TAGS}:
{ tags.map(tag => { diff --git a/themes/next/components/ArticleLock.js b/themes/next/components/ArticleLock.js index 4bb2ef65..3e4a2019 100644 --- a/themes/next/components/ArticleLock.js +++ b/themes/next/components/ArticleLock.js @@ -8,14 +8,12 @@ import { useGlobal } from '@/lib/global' * @returns */ export const ArticleLock = props => { - const { password, validPassword } = props + const { validPassword } = props const { locale } = useGlobal() const submitPassword = () => { const p = document.getElementById('password') - if (p && p.value && p.value === password) { - validPassword(true) - } else { + if (!validPassword(p?.value)) { const tips = document.getElementById('tips') if (tips) { tips.innerHTML = '' diff --git a/themes/next/components/BlogPostCard.js b/themes/next/components/BlogPostCard.js index 43ae9e65..e1bcd070 100644 --- a/themes/next/components/BlogPostCard.js +++ b/themes/next/components/BlogPostCard.js @@ -86,7 +86,7 @@ const BlogPostCard = ({ post, showSummary }) => {
- + {locale.COMMON.ARTICLE_DETAIL} diff --git a/themes/next/components/Footer.js b/themes/next/components/Footer.js index cb83aebe..3e90a5f5 100644 --- a/themes/next/components/Footer.js +++ b/themes/next/components/Footer.js @@ -14,7 +14,7 @@ const Footer = ({ title }) => { return (