mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-09 13:26:08 +10:00
- fix($core): markdown slot doesn‘t work. (regression of c85f62d)
- docs: fresh Node.JS API.
- test: official plugins.
16 lines
444 B
JavaScript
16 lines
444 B
JavaScript
const LRU = require('lru-cache')
|
|
const { fs, path } = require('@vuepress/shared-utils')
|
|
|
|
const cache = new LRU({ max: 1000 })
|
|
|
|
module.exports = function getFragment (dirname, name, fragmentsDir = 'fragments') {
|
|
const target = path.resolve(dirname, `${fragmentsDir}/${name}`)
|
|
let content = cache.get(target)
|
|
if (content) {
|
|
return content
|
|
}
|
|
content = fs.readFileSync(target, 'utf-8')
|
|
cache.set(target, content)
|
|
return content
|
|
}
|