diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js index 52452c52d8c..6079ce513a9 100644 --- a/lib/notion/getPageProperties.js +++ b/lib/notion/getPageProperties.js @@ -3,7 +3,8 @@ import { NotionAPI } from 'notion-client' import BLOG from '@/blog.config' import formatDate from '../formatDate' import { defaultMapImageUrl } from 'react-notion-x' -import { createHash } from 'crypto' +// import { createHash } from 'crypto' +import md5 from 'js-md5' export default async function getPageProperties(id, block, schema, authToken, tagOptions, siteInfo) { const rawProperties = Object.entries(block?.[id]?.value?.properties || []) @@ -91,9 +92,7 @@ export default async function getPageProperties(id, block, schema, authToken, ta properties.page_cover = getImageUrl(block[id].value?.format?.page_cover, block[id].value) ?? siteInfo?.pageCover properties.content = value.content ?? [] properties.password = properties.password - ? createHash('md5') - .update(properties.slug + properties.password) - .digest('hex').trim().toLowerCase() + ? 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/package.json b/package.json index c83a29c232b..b9bfb52abc8 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,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 e5607ed7147..3597161073e 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -9,7 +9,7 @@ import Router from 'next/router' import { isBrowser } from '@/lib/utils' import { getNotion } from '@/lib/notion/getNotion' import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents' -import { createHash } from 'crypto' +import md5 from 'js-md5' /** * 根据notion的slug访问页面 @@ -59,9 +59,8 @@ const Slug = props => { * @param {*} result */ const validPassword = passInput => { - const encrypt = createHash('md5') - .update(post.slug + passInput) - .digest('hex').trim().toLowerCase() + const encrypt = md5(post.slug + passInput) + if (passInput && encrypt === post.password) { setLock(false) return true diff --git a/pages/archive/index.js b/pages/archive/index.js index 700e6273dfe..8c4bc59f6a2 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -45,6 +45,7 @@ export async function getStaticProps() { }) props.archivePosts = archivePosts + delete props.allPages return { props, diff --git a/pages/category/index.js b/pages/category/index.js index f06f4bb0466..f0896ee2a02 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -29,6 +29,7 @@ export async function getStaticProps() { const props = await getGlobalNotionData({ from: 'category-index-props' }) props.categories = getAllCategories({ allPages: props.allPages, categoryOptions: props.categoryOptions, sliceCount: 0 }) delete props.categoryOptions + delete props.allPages return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND diff --git a/pages/index.js b/pages/index.js index b985b7efad2..f27866c38ed 100644 --- a/pages/index.js +++ b/pages/index.js @@ -14,6 +14,7 @@ export async function getStaticProps() { const props = await getGlobalNotionData({ from }) const { siteInfo } = props props.posts = props.allPages.filter(page => page.type === 'Post' && page.status === 'Published') + delete props.allPages const meta = { title: `${siteInfo?.title} | ${siteInfo?.description}`, description: siteInfo?.description, diff --git a/pages/page/[page].js b/pages/page/[page].js index 4a2ae8cc389..0b634f6f20b 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -54,6 +54,7 @@ export async function getStaticProps({ params: { page } }) { } } + delete props.allPages return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND diff --git a/pages/search/[keyword]/page/[page].js b/pages/search/[keyword]/page/[page].js index 92b14f758fd..aa851d3922c 100644 --- a/pages/search/[keyword]/page/[page].js +++ b/pages/search/[keyword]/page/[page].js @@ -43,6 +43,7 @@ export async function getStaticProps({ params: { keyword, page } }) { props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page - 1) props.keyword = keyword props.page = page + delete props.allPages return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND diff --git a/pages/tag/[tag]/index.js b/pages/tag/[tag]/index.js index 29f904a280d..90659ad23bd 100644 --- a/pages/tag/[tag]/index.js +++ b/pages/tag/[tag]/index.js @@ -41,6 +41,7 @@ export async function getStaticProps({ params: { tag } }) { } props.tag = tag + delete props.allPages return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND diff --git a/pages/tag/index.js b/pages/tag/index.js index 6b6f2aba7d7..79be9a57992 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -30,6 +30,7 @@ export async function getStaticProps() { const props = await getGlobalNotionData({ from }) props.tags = getAllTags({ allPages: props.allPages, sliceCount: 0, tagOptions: props.tagOptions }) delete props.tagOptions + delete props.allPages return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND diff --git a/themes/hexo/LayoutBase.js b/themes/hexo/LayoutBase.js index db32f89a9d7..8c0ecac09bd 100644 --- a/themes/hexo/LayoutBase.js +++ b/themes/hexo/LayoutBase.js @@ -11,10 +11,17 @@ import Live2D from '@/components/Live2D' import LoadingCover from './components/LoadingCover' import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' -import FacebookPage from '@/components/FacebookPage' import AOS from 'aos' import 'aos/dist/aos.css' // You can also use for styles import { isBrowser } from '@/lib/utils' +import dynamic from 'next/dynamic' + +const FacebookPage = dynamic( + () => { + return import('@/components/FacebookPage') + }, + { ssr: false } +) /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 diff --git a/themes/nobelium/components/ArticleInfo.js b/themes/nobelium/components/ArticleInfo.js index 64c1cf8c296..6b47c884837 100644 --- a/themes/nobelium/components/ArticleInfo.js +++ b/themes/nobelium/components/ArticleInfo.js @@ -3,16 +3,12 @@ import formatDate from '@/lib/formatDate' import Image from 'next/image' import BLOG from '@/blog.config' import TagItem from './TagItem' -import { createHash } from 'crypto' +import md5 from 'js-md5' export const ArticleInfo = (props) => { const { post } = props - const emailHash = createHash('md5') - .update(BLOG.CONTACT_EMAIL) - .digest('hex') - .trim() - .toLowerCase() + const emailHash = md5(BLOG.CONTACT_EMAIL) return