kerwanp / notion-render

A Javascript library to transform Notion API RichText object into HTML
https://notion-render-docs.vercel.app
Apache License 2.0
98 stars 2 forks source link

Plugins don't work #3

Open cailynyongyong opened 1 year ago

cailynyongyong commented 1 year ago

The plugins for bookmark and hljs don't work.

For example, this is the code I'm running.

import { notFound } from "next/navigation";
import bookmark from "@notion-render/bookmark-plugin";
import { NotionRenderer } from "@notion-render/client";
import hljsPlugin from "@notion-render/hljs-plugin";
import { Client } from "@notionhq/client"
import { fetchPageBlocks, fetchPageBySlug } from "@/lib/notion";

export default async function Page({ params }: { params: { slug: string } }) {
  const post = await fetchPageBySlug("week1")
  if (!post) notFound()

  const blocks = await fetchPageBlocks(post.id)
  const client = new Client({ auth: process.env.NOTION_TOKEN })
  const renderer = new NotionRenderer({ client })

  const html = await renderer.render(...blocks)

  renderer.use(hljsPlugin())
  renderer.use(bookmark())

  return (
    <div
      dangerouslySetInnerHTML={{ __html: html }}
    ></div>
  )
}

The plugin codes return an error saying that "Expected 1 arguments, but got 0.ts(2554) plugin.d.ts(2, 41): An argument for 'config' was not provided."

phips28 commented 11 months ago

its just typescript, use:

  renderer.use(hljsPlugin({}))
  renderer.use(bookmarkPlugin(undefined))