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:
parent
c371303a8a
commit
0f5e9cca70
17
docs/lib/changelog.js
Normal file
17
docs/lib/changelog.js
Normal 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() {
|
||||
}
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user