mirror of
https://github.com/lbr77/blog-astro.git
synced 2026-04-09 00:19:12 +00:00
feat: refactor Notion API integration and update Docker configuration
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user