Created
October 26, 2024 21:05
-
-
Save BluePraise/c4e4897c47a11e1ed8aa8a935defa7f4 to your computer and use it in GitHub Desktop.
Shortcode to show last git commit in 11ty post/page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const childProcess = require('child_process'); | |
| // Add this to .eleventy.js file | |
| eleventyConfig.addShortcode('lastCommitDate', function () { | |
| const lastUpdatedFromGit = childProcess.execSync(`git log -1 --format=%cd --date=short`).toString().trim(); | |
| const formattedDate = DateTime.fromISO(lastUpdatedFromGit).toLocaleString(DateTime.DATETIME_HUGE); | |
| return formattedDate; | |
| }); | |
| // reference post: magaliechetrit.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment