npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@notion-headless-cms/renderer

v0.1.6

Published

Markdown to HTML renderer using remark/rehype for notion-headless-cms

Readme

@notion-headless-cms/renderer

Markdown → HTML レンダラー。remark / rehype(unified)パイプラインで変換する。 GFM(テーブル / 打ち消し線など)と Notion 画像 URL のプロキシ書き換えをデフォルトでサポートする。

インストール

npm install @notion-headless-cms/renderer \
  unified remark-parse remark-gfm remark-rehype rehype-stringify

unified / remark-* / rehype-*peerDependencies。複数バージョン同居による unified の Processor インスタンス不一致を避けるため、利用側のアプリが明示的にインストールする。

通常は @notion-headless-cms/corecreateCMS() 経由で使う。 renderer は未指定の場合、core が動的 import でフォールバック注入する。 明示的に差し替えたい場合は nodePreset({ renderer: renderMarkdown })createCMS({ renderer: renderMarkdown, ... }) で注入する。

使い方

import { renderMarkdown } from "@notion-headless-cms/renderer";

const html = await renderMarkdown("# Hello\n\nWorld");
// "<h1>Hello</h1>\n<p>World</p>"

画像プロキシ

Notion 画像 URL は期限付きのため、cacheImage を渡せば画像を永続ストレージに保存した上でプロキシ URL に書き換えられる。core 内部ではキャッシュと連携した cacheImage が自動注入される。

import { renderMarkdown } from "@notion-headless-cms/renderer";

const html = await renderMarkdown(markdown, {
  imageProxyBase: "/api/images",
  cacheImage: async (notionUrl) => {
    const hash = await storeAndHash(notionUrl);
    return `/api/images/${hash}`;
  },
});

追加のプラグイン

import rehypeHighlight from "rehype-highlight";
import type { PluggableList } from "@notion-headless-cms/renderer";
import { renderMarkdown } from "@notion-headless-cms/renderer";

const rehypePlugins: PluggableList = [rehypeHighlight];

const html = await renderMarkdown(markdown, {
  rehypePlugins,
});

PluggableListunified の公開型を再エクスポートしたもの。core 側の RenderOptions.remarkPlugins / rehypePlugins も同じ型。

パイプラインを完全置き換え

render を渡すと remark/rehype パイプラインを使わず独自の実装に差し替えられる。

import type { RendererFn } from "@notion-headless-cms/renderer";
import { renderMarkdown } from "@notion-headless-cms/renderer";

const myRenderer: RendererFn = async (markdown) => `<pre>${markdown}</pre>`;

const html = await renderMarkdown(markdown, { render: myRenderer });

API

renderMarkdown(markdown, options?): Promise<string>

| オプション | 型 | 説明 | |---|---|---| | imageProxyBase | string | 画像プロキシのベース URL(デフォルト: /api/images) | | cacheImage | (notionUrl: string) => Promise<string> | Notion 画像 URL を永続化して URL を返す関数。未指定時は URL をそのまま使う | | remarkPlugins | PluggableList | 追加する remark プラグイン | | rehypePlugins | PluggableList | 追加する rehype プラグイン | | render | RendererFn | デフォルトパイプラインを置き換えるカスタムレンダラー |

  • RendererFn(markdown, options?) => Promise<string>。core の RendererFn と構造的互換。
  • RendererOptionsrenderMarkdown のオプション型。
  • PluggableListunified の再エクスポート。remarkPlugins / rehypePlugins の型。

関連パッケージ