0.1.0 • Published 3 years ago

frontmatter-date-setter v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

This package adds git file creation and modification dates to yaml frontmatter. Give it a directory and some file extensions and it will do the rest.

If a creation or modification date is already present, they will be updated if they don't match.

Example

Input

---
title: Frontmatter Date Setter
---

Output

---
title: Frontmatter Date Setter
created: 2020-03-22T14:53:49.000Z
modified: 2020-03-22T14:53:49.000Z
---

Installation

yarn add frontmatter-date-setter
# or
npm install frontmatter-date-setter

For CLI use you may want to install it globally

yarn global add frontmatter-date-setter
# or
npm install -g frontmatter-date-setter

Usage

Node

const fds = require('frontmatter-date-setter')

fds({
  directory: './tests',
  fileExtension: ['.md', '.mdx'],
  debug: true,
})

CLI

  Usage
    $ frontmatter-date-setter <input>
    $ fds <input>

  Options
    --directory, -d  The directory of the files to add dates to
    --fileExtension, -ext  The file extensions that you wish to add dates to
    --debug Turn on debugging messages

  Examples
    $ frontmatter-date-setter --directory="notes" --fileExtension=.md  --fileExtension=.mdx
    $ fds --directory="notes" --fileExtension=.md  --fileExtension=.mdx

CLI Example

frontmatter-date-setter --directory="notes" --fileExtension=md  --fileExtension=mdx
fds --directory="tests" --fileExtension=.txt --fileExtension=.md --fileExtension=.yml --debug

License

MIT © Zander Martineau

Made by Zander • zander.wtfGitHubTwitter