Skip to content

Instantly share code, notes, and snippets.

@mheadd
Created August 3, 2021 16:32
Show Gist options
  • Save mheadd/c8d9d5e3b7caad4398c12c54767670d1 to your computer and use it in GitHub Desktop.
Save mheadd/c8d9d5e3b7caad4398c12c54767670d1 to your computer and use it in GitHub Desktop.
const { batch } = require('frontmatter-file-batcher');
// The name of the file to modify.
const file_name = process.argv[2];
// The name of the new front matter property to add.
let fm_property = process.argv[3];
// The value of the new front matter property
let fm_value = process.argv[4];
batch(`content/${file_name}`, 1, async ({ goods, actions }) => {
const { update, save } = actions;
var data = {};
data[fm_property] = { $set: fm_value };
const newData = update({ data });
await save(newData);
console.log('Just saved:', goods.path);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment