How to use the @vuepress/markdown-loader.frontmatterEmitter.emit function in @vuepress/markdown-loader

To help you get started, we’ve selected a few @vuepress/markdown-loader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vuepress / packages / @vuepress / core / lib / internal-plugins / frontmatterBlock / loader.js View on Github external
module.exports = function (source, map) {
  const isProd = process.env.NODE_ENV === 'production'

  if (!isProd) {
    const file = this.resourcePath
    // frontmatter changed... need to do a full reload
    const cached = cache.get(file)
    const parsed = parseStrippedFrontmatter(source)

    if (cached &&
      cached.data &&
      parsed &&
      parsed.data &&
      JSON.stringify(cached.data) !== JSON.stringify(parsed.data)
    ) {
      frontmatterEmitter.emit('update')
    }

    cache.set(file, parsed)
  }

  this.callback(null, '', map)
}

@vuepress/markdown-loader

markdown-loader for vuepress

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis