最后更新时间

This commit is contained in:
tangly1024
2022-04-06 15:45:24 +08:00
parent ac51b696cd
commit ef62044a99
11 changed files with 125 additions and 68 deletions

View File

@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
import { NotionAPI } from 'notion-client'
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
export async function getPostBlocks (id, from, slice, retryCount = 3) {
export async function getPostBlocks(id, from, slice, retryCount = 3) {
const cacheKey = 'page_block_' + id
let pageBlock = await getDataFromCache(cacheKey)
if (pageBlock) {
@@ -32,13 +32,13 @@ export async function getPostBlocks (id, from, slice, retryCount = 3) {
}
/**
*
* 获取到的blockMap删除不需要的字段
* @param {*} id 页面ID
* @param {*} pageBlock 页面元素
* @param {*} slice 截取数量
* @returns
*/
function filterPostBlocks (id, pageBlock, slice) {
function filterPostBlocks(id, pageBlock, slice) {
const clonePageBlock = deepClone(pageBlock)
let count = 0
@@ -51,8 +51,6 @@ function filterPostBlocks (id, pageBlock, slice) {
count++
delete b?.role
delete b?.value?.version
delete b?.value?.created_time
delete b?.value?.last_edited_time
delete b?.value?.created_by_table
delete b?.value?.created_by_id
delete b?.value?.last_edited_by_table
@@ -67,7 +65,7 @@ function filterPostBlocks (id, pageBlock, slice) {
return clonePageBlock
}
function deepClone (obj) {
function deepClone(obj) {
const newObj = Array.isArray(obj) ? [] : {}
if (obj && typeof obj === 'object') {
for (const key in obj) {