feat(使用全局变量的 notionAPI): 避免多次创建NotionAPI,有效利用内置的concurrency并发请求限制

This commit is contained in:
anime
2025-01-04 01:00:49 +08:00
parent 2831d2fb0c
commit 019f5e470f
3 changed files with 12 additions and 14 deletions

View File

@@ -1,10 +1,14 @@
import { NotionAPI } from 'notion-client'
import { NotionAPI as NotionLibrary } from 'notion-client'
import BLOG from '@/blog.config'
export default function getNotionAPI() {
return new NotionAPI({
const notionAPI = getNotionAPI()
function getNotionAPI() {
return new NotionLibrary({
activeUser: BLOG.NOTION_ACTIVE_USER || null,
authToken: BLOG.NOTION_TOKEN_V2 || null,
userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
})
}
export default notionAPI