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