UNPKG

@r4ai/remark-embed

Version:

[![JSR](https://jsr.io/badges/@r4ai/remark-embed)](https://jsr.io/@r4ai/remark-embed) [![codecov](https://codecov.io/gh/r4ai/remark-embed/graph/badge.svg?token=B9EZXC0PR8)](https://codecov.io/gh/r4ai/remark-embed) [![CI](https://github.com/r4ai/remark-emb

53 lines (47 loc) 1.28 kB
import type { ElementContent, Properties } from "hast" /** * For example implementations, see the [transformers](./transformers/index.ts) directory. */ export type Transformer = { /** * The name of the transformer. * * @example "oembed" */ name: string /** * The tag name of the element. * * @example "iframe", "img", "a" */ tagName: string | ((url: URL) => string) | ((url: URL) => Promise<string>) /** * The properties of the element. * * @example { className: "oembed" } * @example (url) => ({ src: url.href, alt: "Image" }) */ properties: | ((url: URL) => Properties) | ((url: URL) => Promise<Properties>) | Properties /** * The children of the element. * * @example [{ type: "text", value: "Hello, World!" }] * @example (url) => [{ type: "text", value: url.href }] */ children: | ElementContent[] | ((url: URL) => ElementContent[]) | ((url: URL) => Promise<ElementContent[]>) /** * The URL matcher. * If the URL is matched, the transformer will be applied. * * @param url The URL to match. * @returns Whether the URL is matched. * @example (url) => url.hostname === "example.com" */ match: ((url: URL) => boolean) | ((url: URL) => Promise<boolean>) }