Skip to main content

Set the last modified date in YAML front matter of edited markdown files.

Project description

yaml-update-last-modified-date

Automatically set the last modified date in YAML front matter of edited markdown files.

Quick start

  1. cd into a folder containing a git repository.
  2. git add a modified markdown (.md) file that has last_modified_at in its YAML front matter.
  3. Get this script: curl --location --remote-name https://raw.githubusercontent.com/proinsias/yaml-update-last-modified-date/main/yaml-update-last-modified-date
  4. Run the script: bash yaml-update-last-modified-date.

This script will:

  1. Look for markdown files that differ from the current HEAD,
  2. Check to see if they contain the specified last-modified-date variable (last_modified_at by default) in their YAML front matter, if present, and
  3. Update the value of that variable to the current Universal Time Coordinated (UTC) time.

See below for instructions on how to install this script as a local command or as a pre-commit git hook.

Table of Contents

Installation yaml-update-last-modified-date via homebrew

If necessary, first install homebrew!

Then:

brew install proinsias/yaml-update-last-modified-date/yaml-update-last-modified-date

Using yaml-update-last-modified-date with pre-commit

Add this to your .pre-commit-config.yaml:

- repo: https://github.com/proinsias/yaml-update-last-modified-date
  rev: '' # Use the sha / tag you want to point at
  hooks:
      - id: yaml-update-last-modified-date

Credits

Thanks to Michael Rose for the original script.

License

See LICENSE.

Updating the Table of Contents of this file

We use markdown-toc to automatically generate the table of contents for this file. You can update the TOC using:

# npm install --global markdown-toc

markdown-toc -i README.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaml_update_last_modified_date-1.1.1.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page