feat: refactor Notion API integration and update Docker configuration

This commit is contained in:
2026-03-16 14:39:18 +08:00
parent 8bb135a489
commit 7faa73c91f
10 changed files with 180 additions and 353 deletions

View File

@@ -1,14 +1,11 @@
import type { Post } from '../interfaces'
import { fetchNotionApiJson } from './api'
export async function getPostByPageId(pageId: string): Promise<Post | null> {
if (!pageId) return null
try {
const res = await fetch("https://notion-api.nvme0n1p.dev/v2/posts")
if (!res.ok) throw new Error(`Failed to fetch posts: ${res.status}`)
const payload = (await res.json()) as { posts?: any[] }
const payload = await fetchNotionApiJson<{ posts?: any[] }>('/v2/posts')
const match = (payload.posts ?? []).find((post) => post.id === pageId)
if (!match) return null