mirror of
https://github.com/alrayyes/wiki.git
synced 2025-05-02 06:58:13 +00:00
rss + sitemap
This commit is contained in:
parent
ba9f243728
commit
4c904d88ab
11 changed files with 131 additions and 491 deletions
quartz/plugins/transformers
|
@ -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('.')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue