Skip to content

pantoken-root / renderers/rehype/src / rehypePantokenIcons

ฟังก์ชัน: rehypePantokenIcons() ​

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

ทดลอง

ฟังก์ชันสร้างปลั๊กอิน rehype. คืนค่าตัวแปลงที่เขียนทับโทเค็น :code: ให้เป็น SVG แบบฝัง

พารามิเตอร์ ​

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");

สร้างตัวแก้ (resolver) สำหรับปลั๊กอิน brand-icon

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.