mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-10 22:06:22 +10:00
21 lines
451 B
JavaScript
21 lines
451 B
JavaScript
import fs from 'fs-extra'
|
|
import LRU from 'lru-cache'
|
|
import path from 'path'
|
|
|
|
const cache = new LRU({ max: 1000 })
|
|
|
|
export function Md () {
|
|
return require('markdown-it')()
|
|
}
|
|
|
|
export async function getFragment (name) {
|
|
let content = cache.get(name)
|
|
if (content) {
|
|
return content
|
|
}
|
|
const target = path.resolve(__dirname, `fragments/${name}.md`)
|
|
content = await fs.readFile(target, 'utf-8')
|
|
cache.set(name, content)
|
|
return content
|
|
}
|