Skip to content
Snippets Groups Projects
Commit fb012ce3 authored by wu-lee's avatar wu-lee
Browse files

metalsmith.js - workaround metalsmith bug in persistent env

Basically we need to reset all the metadata or we get the news pages
appended to collections.

https://github.com/segmentio/metalsmith-collections/issues/27
parent 4ec31ccb
Branches live
No related tags found
No related merge requests found
......@@ -83,7 +83,13 @@ function elideMeta(meta) {
};
}
module.exports = Metalsmith(__dirname)
// We return a function building the metalsmith object.
// This works around a metalsmith bug when run in a persistent environment.
// https://github.com/segmentio/metalsmith-collections/issues/27
// Another solution here:
// https://destinmoulton.com/blog/2018/metalsmith-collections-solving-the-duplication-bug/
module.exports = () => {
return Metalsmith(__dirname)
.metadata({
// These defaults can be overridden in pages
sitename: "Social Coop",
......@@ -124,10 +130,11 @@ module.exports = Metalsmith(__dirname)
}))
.use(forFiles((d,f) => buildlog.silly(f,elideMeta(d))))
.use(assets());
};
if (require.main === module) {
// Called directly, build
module.exports.build(function(err) {
module.exports().build(function(err) {
if (!err) return;
console.error('Build failed: '+err);
process.exit(1);
......
......@@ -42,7 +42,7 @@ var fileOptions = {
async function build() {
buildlog.info('starting build...')
metalsmith.build(function(err) {
metalsmith().build(function(err) {
if (err)
buildlog.error('build exception', err);
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment