mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
18 lines
531 B
JavaScript
18 lines
531 B
JavaScript
import BLOG from '@/blog.config'
|
|
import { NotionAPI } from 'notion-client'
|
|
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
|
|
|
|
export async function getPostBlocks (id) {
|
|
let pageBlock = await getDataFromCache('page_block_' + id)
|
|
if (pageBlock) {
|
|
return pageBlock
|
|
}
|
|
const authToken = BLOG.notionAccessToken || null
|
|
const api = new NotionAPI({ authToken })
|
|
pageBlock = await api.getPage(id)
|
|
if (pageBlock) {
|
|
await setDataToCache('page_block_' + id, pageBlock)
|
|
}
|
|
return pageBlock
|
|
}
|