fix: escape encoding for titles in rss

This commit is contained in:
Jacky Zhao 2023-09-06 21:47:59 -07:00
parent ef1ead31dc
commit 828aa71fe3
3 changed files with 15 additions and 14 deletions
quartz/plugins/transformers

View file

@ -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 @@ const defaultOptions: Options = {
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 {