toc
Jacky Zhao
2023-06-10 b8c011410d6bcd6837f4efd6a3948196a0f7aeea
quartz/plugins/transformers/description.ts
@@ -15,7 +15,7 @@
  name = "Description"
  opts: Options
  constructor(opts?: Options) {
  constructor(opts?: Partial<Options>) {
    super()
    this.opts = { ...defaultOptions, ...opts }
  }
@@ -29,7 +29,9 @@
      () => {
        return async (tree: HTMLRoot, file) => {
          const frontMatterDescription = file.data.frontmatter?.description
          const desc = frontMatterDescription ?? toString(tree)
          const text = toString(tree)
          const desc = frontMatterDescription ?? text
          const sentences = desc.replace(/\s+/g, ' ').split('.')
          let finalDesc = ""
          let sentenceIdx = 0
@@ -40,6 +42,7 @@
          }
          file.data.description = finalDesc
          file.data.text = text
        }
      }
    ]
@@ -49,6 +52,7 @@
declare module 'vfile' {
  interface DataMap {
    description: string
    text: string
  }
}