主题,加密

This commit is contained in:
tangly1024
2022-12-24 19:08:10 +08:00
parent e9fc7b9ea3
commit ef4daf4cf6
8 changed files with 16 additions and 10 deletions

View File

@@ -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' }
}) || []