diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js index ef93f84b..52452c52 100644 --- a/lib/notion/getPageProperties.js +++ b/lib/notion/getPageProperties.js @@ -3,7 +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' +import { createHash } from 'crypto' export default async function getPageProperties(id, block, schema, authToken, tagOptions, siteInfo) { const rawProperties = Object.entries(block?.[id]?.value?.properties || []) @@ -90,7 +90,11 @@ 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.password = properties.password + ? createHash('md5') + .update(properties.slug + properties.password) + .digest('hex').trim().toLowerCase() + : '' 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 d35fc0a4..ad6de107 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "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 6ca98c93..b4e1d47e 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -8,8 +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' +import { createHash } from 'crypto' /** * 根据notion的slug访问页面 @@ -59,7 +59,10 @@ const Slug = props => { * @param {*} result */ const validPassword = passInput => { - if (passInput && md5(post.slug + passInput) === post.password) { + const encrypt = createHash('md5') + .update(post.slug + passInput) + .digest('hex').trim().toLowerCase() + if (passInput && encrypt === post.password) { setLock(false) return true } diff --git a/themes/example/components/ArticleLock.js b/themes/example/components/ArticleLock.js index 43b6647e..6e90f7b2 100644 --- a/themes/example/components/ArticleLock.js +++ b/themes/example/components/ArticleLock.js @@ -25,7 +25,7 @@ export const ArticleLock = props => { return
{locale.COMMON.ARTICLE_LOCK_TIPS}
-
+
 {locale.COMMON.SUBMIT} diff --git a/themes/fukasawa/components/ArticleLock.js b/themes/fukasawa/components/ArticleLock.js index 8ae18a4e..1dedba16 100644 --- a/themes/fukasawa/components/ArticleLock.js +++ b/themes/fukasawa/components/ArticleLock.js @@ -27,7 +27,7 @@ export const ArticleLock = props => {
{locale.COMMON.ARTICLE_LOCK_TIPS}
-
+
{ return
{locale.COMMON.ARTICLE_LOCK_TIPS}
-
+
 {locale.COMMON.SUBMIT} diff --git a/themes/medium/components/ArticleLock.js b/themes/medium/components/ArticleLock.js index 1e1bb228..aa870ac5 100644 --- a/themes/medium/components/ArticleLock.js +++ b/themes/medium/components/ArticleLock.js @@ -25,7 +25,7 @@ export const ArticleLock = props => { return
{locale.COMMON.ARTICLE_LOCK_TIPS}
-
+
 {locale.COMMON.SUBMIT} diff --git a/themes/next/components/ArticleLock.js b/themes/next/components/ArticleLock.js index 3e4a2019..1f1c6b6b 100644 --- a/themes/next/components/ArticleLock.js +++ b/themes/next/components/ArticleLock.js @@ -27,7 +27,7 @@ export const ArticleLock = props => {
{locale.COMMON.ARTICLE_LOCK_TIPS}
-
+