Jacky Zhao
2023-09-07 828aa71fe34aae675a7552957e8a062c82f595f6
quartz/plugins/transformers/description.ts
@@ -1,6 +1,7 @@
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
@@ -10,15 +11,6 @@
  descriptionLength: 150,
}
const escapeHTML = (unsafe: string) => {
  return unsafe
    .replaceAll("&", "&")
    .replaceAll("<", "&lt;")
    .replaceAll(">", "&gt;")
    .replaceAll('"', "&quot;")
    .replaceAll("'", "&#039;")
}
export const Description: QuartzTransformerPlugin<Partial<Options> | undefined> = (userOpts) => {
  const opts = { ...defaultOptions, ...userOpts }
  return {