mirror of
https://github.com/primer/css.git
synced 2024-12-12 10:47:14 +03:00
14 lines
501 B
JavaScript
14 lines
501 B
JavaScript
const grayMatter = require('gray-matter')
|
|
const fs = require('fs')
|
|
const {join} = require('path')
|
|
|
|
const searchIndex = {}
|
|
const searchIndexPath = join(process.cwd(), 'searchIndex.js')
|
|
|
|
module.exports = function(source) {
|
|
const {data, content} = grayMatter(source)
|
|
searchIndex[data.path] = Object.assign({title: data.title, path: data.path, keywords: data.keywords}, {content})
|
|
fs.writeFileSync(searchIndexPath, `export default ${JSON.stringify(searchIndex, null, 2)}`, 'utf8')
|
|
return source
|
|
}
|