| | |
| | | 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 { |
| | | name: "Description", |
| | | markdownPlugins() { |
| | | return [] |
| | | }, |
| | | htmlPlugins() { |
| | | return [ |
| | | () => { |
| | | return async (tree: HTMLRoot, file) => { |
| | | const frontMatterDescription = file.data.frontmatter?.description |
| | | const text = toString(tree) |
| | | const text = escapeHTML(toString(tree)) |
| | | |
| | | const desc = frontMatterDescription ?? text |
| | | const sentences = desc.replace(/\s+/g, ' ').split('.') |