1
1
mirror of https://github.com/primer/css.git synced 2024-11-23 20:38:58 +03:00

add metadata to the changelog

This commit is contained in:
Shawn Allen 2018-12-07 11:29:26 -08:00
parent c371303a8a
commit 0f5e9cca70
2 changed files with 25 additions and 3 deletions

17
docs/lib/changelog.js Normal file
View File

@ -0,0 +1,17 @@
const {readFileSync} = require('fs')
module.exports = function addChangelog(sourcePath, destPath, transform = noop) {
return (files, metal, done) => {
const path = metal.path(metal.source(), sourcePath)
const file = {
contents: readFileSync(path),
path: destPath
}
transform(file)
files[destPath] = file
done()
}
}
function noop() {
}

View File

@ -3,6 +3,7 @@ const filter = require('metalsmith-filter')
const frontmatter = require('metalsmith-matters')
const watch = require('metalsmith-watch')
const addChangelog = require('./changelog')
const addPackageMeta = require('./add-package-meta')
const addSource = require('./add-source')
const filterBy = require('./filter-by')
@ -53,14 +54,18 @@ module.exports = function sync(options = {}) {
)
// rename files with their "path" frontmatter key
.use(rename(file => `${file[ns].path}.md`), {log})
// write frontmatter back out to the file
.use(writeMeta(metaOptions))
.use(addChangelog('../CHANGELOG.md', 'whats-new/changelog.md', file => {
file[ns] = {
title: 'Changelog'
}
}))
// read the changelog manually
.use((_files, metal, done) => {
_files['whats-new/changelog.md'] = metal.readFile('../CHANGELOG.md')
files = _files
done()
})
// write frontmatter back out to the file
.use(writeMeta(metaOptions))
// keep .gitignore up-to-date with the list of generated files
.use(
gitIgnore({