import { loader } from 'webpack' import LRU from 'lru-cache' import hash from 'hash-sum' import markdownIt from './markdown' const cache = new LRU({ max: 1000 }) export default function (this: loader.LoaderContext, markdown: string) { // Check cache const key = hash(this.resourcePath + markdown) if (cache.has(key)) { return cache.get(key) } // Parse markdown const md = markdownIt() const parsedContent = md.render(markdown) cache.set(key, parsedContent) return parsedContent }