Explorar o código

feat: add sitemap (fix bug)

rriecc %!s(int64=2) %!d(string=hai) anos
pai
achega
2b3d5c5686
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      lib/notion.ts

+ 9 - 0
lib/notion.ts

@@ -1,11 +1,20 @@
 import { NotionAPI } from "notion-client";
 import { Block } from "notion-types";
+import { getPageTitle } from "notion-utils";
 
 import { Blog } from "@/types/blog";
 import { notionBlogConfig } from "@/config/site";
 
 const notion = new NotionAPI();
 
+export async function getPageContent(pageId: string) {
+  const recordMap = await notion.getPage(pageId);
+  const title = getPageTitle(recordMap);
+  const blocks = recordMap.block;
+
+  return { title, blocks, recordMap };
+}
+
 export async function getAllBlogPosts(pageId: string) {
   const recordMap = await notion.getPage(pageId);
   const blocks = recordMap.block;