rss + sitemap
This commit is contained in:
		@@ -10,6 +10,10 @@ const defaultOptions: Options = {
 | 
			
		||||
  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 {
 | 
			
		||||
@@ -19,7 +23,7 @@ export const Description: QuartzTransformerPlugin<Partial<Options> | undefined>
 | 
			
		||||
        () => {
 | 
			
		||||
          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('.')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user