Skip to content

pantoken / renderers/rehype/src / rehypePantokenIcons

함수: rehypePantokenIcons()

rehypePantokenIcons(options?): (tree) => void

실험적

rehype 플러그인 팩토리입니다. 인라인 SVG로 :code: 토큰을 재작성하는 변환기를 반환합니다.

매개변수

options?

RehypeOptions = {}

RehypeOptions.

반환값

unified/rehype 변환기입니다.

(tree) => void

예제들

내장 아이콘 세트

ts
import { unified } from "unified";
import rehypeParse from "rehype-parse";
import rehypeRaw from "rehype-raw";
import rehypeStringify from "rehype-stringify";
import { rehypePantokenIcons } from "@pantoken/rehype";

const html = await unified()
  .use(rehypeParse, { fragment: true })
  .use(rehypePantokenIcons)
  .use(rehypeRaw) // required: the icon body is a raw SVG node
  .use(rehypeStringify)
  .process("go :arrow-left: back");

브랜드 아이콘 플러그인의 리졸버 구성

ts
import { rehypePantokenIcons } from "@pantoken/rehype";
import { simpleIcons } from "@pantoken/plugin-simple-icons";
import * as registry from "simple-icons";

unified().use(rehypePantokenIcons, { plugins: [simpleIcons({ registry })] });
// :github: now resolves from simple-icons; unknown codes stay literal text.