Skip to content

Commit

Permalink
package
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Jan 6, 2023
1 parent bf25721 commit 6cfd429
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 15 deletions.
7 changes: 3 additions & 4 deletions lib/notion/getPageProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || [])
Expand Down Expand Up @@ -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' }
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions pages/[...slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -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访问页面
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pages/archive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function getStaticProps() {
})

props.archivePosts = archivePosts
delete props.allPages

return {
props,
Expand Down
1 change: 1 addition & 0 deletions pages/category/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions pages/page/[page].js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function getStaticProps({ params: { page } }) {
}
}

delete props.allPages
return {
props,
revalidate: BLOG.NEXT_REVALIDATE_SECOND
Expand Down
1 change: 1 addition & 0 deletions pages/search/[keyword]/page/[page].js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pages/tag/[tag]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function getStaticProps({ params: { tag } }) {
}

props.tag = tag
delete props.allPages
return {
props,
revalidate: BLOG.NEXT_REVALIDATE_SECOND
Expand Down
1 change: 1 addition & 0 deletions pages/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion themes/hexo/LayoutBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <link> for styles
import { isBrowser } from '@/lib/utils'
import dynamic from 'next/dynamic'

const FacebookPage = dynamic(
() => {
return import('@/components/FacebookPage')
},
{ ssr: false }
)

/**
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏
Expand Down
8 changes: 2 additions & 6 deletions themes/nobelium/components/ArticleInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <section className="flex-wrap flex mt-2 text-gray--600 dark:text-gray-400 font-light leading-8">
<div>
Expand Down

0 comments on commit 6cfd429

Please sign in to comment.