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