UNPKG

astro-notion-loader

Version:

A simple loader for fetching and converting Notion database content to markdown, designed for Astro and other static site generators

61 lines (57 loc) 1.66 kB
import { z } from 'zod'; export interface NotionPage { id: string; title: string; description: string; pubDate: Date; status: string; content: string; } export interface NotionFilter { property: string; [key: string]: any; } /** * Loads and converts Notion database pages to markdown format * @param options - Configuration object * @param options.notionAPIKey - Your Notion API integration token * @param options.notionDatabaseId - The ID of the Notion database to query * @param options.filter - Optional filter object to apply to the database query * @returns Promise that resolves to an array of converted pages */ export declare function loader({ notionAPIKey, notionDatabaseId, filter }: { notionAPIKey: string; notionDatabaseId: string; filter?: NotionFilter; }): Promise<NotionPage[]>; /** * Returns an Astro content collection configuration for Notion database * @param options - Configuration object * @param options.notionAPIKey - Your Notion API integration token * @param options.notionDatabaseId - The ID of the Notion database to query * @param options.filter - Optional filter object to apply to the database query * @returns Content collection configuration object */ export declare function getCollection({ notionAPIKey, notionDatabaseId, filter }: { notionAPIKey: string; notionDatabaseId: string; filter?: NotionFilter; }): { loader: () => Promise<NotionPage[]>; schema: ({ image }: { image: any }) => z.ZodObject<{ id: z.ZodString; title: z.ZodString; description: z.ZodString; pubDate: z.ZodDate; status: z.ZodString; content: z.ZodString; }>; };