fix/article-password

This commit is contained in:
tangly1024.com
2023-04-18 14:35:47 +08:00
parent d1fef2aa31
commit 9da98de56d
3 changed files with 35 additions and 10 deletions

View File

@@ -4,6 +4,11 @@ import formatDate from '../formatDate'
import { getPostBlocks } from './getPostBlocks'
import { defaultMapImageUrl } from 'react-notion-x'
/**
* 根据页面ID获取内容
* @param {*} pageId
* @returns
*/
export async function getNotion(pageId) {
const blockMap = await getPostBlocks(pageId, 'slug')
if (!blockMap) {

View File

@@ -3,6 +3,13 @@ import { NotionAPI } from 'notion-client'
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
import { deepClone, delay } from '../utils'
/**
* 获取文章内容
* @param {*} id
* @param {*} from
* @param {*} slice
* @returns
*/
export async function getPostBlocks(id, from, slice) {
const cacheKey = 'page_block_' + id
let pageBlock = await getDataFromCache(cacheKey)
@@ -71,6 +78,13 @@ function filterPostBlocks(id, pageBlock, slice) {
delete clonePageBlock?.block[i]
continue
}
// 当BlockId等于PageId时移除
if (b?.value?.id === id) {
// 此block含有敏感信息
delete b?.value?.properties
continue
}
count++
// 处理 c++、c#、汇编等语言名字映射
if (b?.value?.type === 'code') {