Giter VIP home page Giter VIP logo

front-matter-manipulator's Introduction

Front Matter Manipulator

A utility for parsing and manipulating documents with Front Matter. Get the fields, values for any collection of documents. Bulk update, delete, or rename fields.

Getting Started

This utility can be used as a Command Line Interface, or as an import in your scripts.

It has two primary uses:

  • Parsing one or many files to discover the content model
  • Updating the content model of one or many files

This is done through the following commands:

  • fields: finds all fields in specified files
  • values: finds all values for specified fields in specified files
  • update: update the value for specified field in specified files
  • rename: update the name of specified field in specified files
  • drop: delete the specified fields from the specified files
  • convert: convert any field to an array

Installation

Install CLI

Run the following command:

npm install -g front-matter-manipulator

Install in current directory for use in scripts

npm install front-matter-manipulator --save-dev

CLI (Command Line Interface)

Front Matter Manipulator can be used on the command line to perform operations on fields.

See the documentation for each action:

Usage in node scripts/packages

Front Matter Manipulator can be used on in javascript files to perform advanced parsing or manipulation of fields.

See the documentation for each action:

front-matter-manipulator's People

Contributors

chrisdmacrae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lunaticmuch

front-matter-manipulator's Issues

Add ability to add new data set

It would really be great if update was able to add a new data key/value pair when passing an in-existing key as argument.

The current behaviour when doing the above is a successfully updated list of items. Yet the data set is not added.

Add a merge command

Problem's we're trying to solve

In some cases, you may have many fields that are very similar or are used for the same purpose, and want to consolidate these to have leaner FMTs.

This currently requires a lot of tedious, manual work. Having a utility that finds all possible values for each key, and allows you to merge them / pick a preferred value for a single (or new key) would be ideal for site migration and updating.

  • Add ability to query the values of a file by key
  • Allow the specification of the replacement key
  • Prompt the user for the correct value
  • Allow the user to optionally specify a "winner cascade", where values don't need to be confirmed, but are used in order found. (E.g, --by-fields description,summary,excerpt)

Convert to fully async, promise-based

Problem we're trying to solve

Currently the commands are written partially synchronous, which means the I/O can be blocked when reading many files or updating many files.

Moving to promise-based async will allow the commands to run much faster.

General

  • Update update to be async
  • Update rename to be async
  • Update valuesto be async
  • Update fields to be async

Specific

  • Update all array functions to be async
  • Update all readFileSync and writeFileSync to be async
  • Update all glob actions to be async

Add drop command

Problem's we're trying to solve

In some cases you may have a bunch of extra fields that you no longer need, being able to batch remove them from many files is ideal.

Currently, either the CMS you use must do this, you must do it by hand, or by writing a script.

  • Allow specifying many fields to be dropped from the globbed files
  • Ensure that a confirmation is used by default, as this destructive behaviour is not easily undone without version control

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.