Automatically set the last modified date in YAML front matter of edited markdown files.
Just cd
into a folder containing a git repository, and run:
curl --location --remote-name \
https://raw.githubusercontent.com/proinsias/yaml-update-last-modified-date/main/yaml-update-last-modified-date \
&& /usr/bin/env bash yaml-update-last-modified-date
This script will:
- look for markdown files that differ from the current
HEAD
, - check to see if they contain the specified last-modified-date variable (
last modified date
by default) in their YAML front matter, if present, and - 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.
If necessary, first install homebrew!
Then:
brew install proinsias/yaml-update-last-modified-date/yaml-update-last-modified-date
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
Thanks to Michael Rose for the original script.
See LICENSE.
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