Skip to main content
本示例介绍如何从 Notion 仪表板导出的 Notion 页面加载数据。 首先,按照官方 Notion 导出说明,将您的 Notion 页面导出为 Markdown & CSV 格式。请确保选中 包含子页面为子页面创建文件夹 选项。 然后,解压下载的文件,并将解压后的文件夹移动到您的仓库中。该文件夹应包含您页面的 markdown 文件。 一旦文件夹放入您的仓库,只需运行以下示例:
import { NotionLoader } from "@langchain/community/document_loaders/fs/notion";

export const run = async () => {
  /** 提供您的 Notion 文件夹的目录路径 */
  const directoryPath = "Notion_DB";
  const loader = new NotionLoader(directoryPath);
  const docs = await loader.load();
  console.log({ docs });
};