| | |
| | | import { Root as HTMLRoot } from "hast" |
| | | import { toString } from "hast-util-to-string" |
| | | import { QuartzTransformerPlugin } from "../types" |
| | | import { escapeHTML } from "../../util/escape" |
| | | |
| | | export interface Options { |
| | | descriptionLength: number |
| | |
| | | descriptionLength: 150, |
| | | } |
| | | |
| | | const escapeHTML = (unsafe: string) => { |
| | | return unsafe |
| | | .replaceAll("&", "&") |
| | | .replaceAll("<", "<") |
| | | .replaceAll(">", ">") |
| | | .replaceAll('"', """) |
| | | .replaceAll("'", "'") |
| | | } |
| | | |
| | | export const Description: QuartzTransformerPlugin<Partial<Options> | undefined> = (userOpts) => { |
| | | const opts = { ...defaultOptions, ...userOpts } |
| | | return { |