mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-01 23:16:51 +00:00
Code🤣
This commit is contained in:
17
lib/notion/getPostBlocks.js
Normal file
17
lib/notion/getPostBlocks.js
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user