UNPKG

eleventy-plugin-git-commit-date

Version:

Eleventy plugin to get Git commit time of a file, or a Eleventy collection.

24 lines (18 loc) 600 B
// @ts-check import { getRepoGitCommitDateMap } from "./utils/git.js"; async function initGetGitCommitDateFromPath() { const fileMap = await getRepoGitCommitDateMap(); function getGitCommitDateFromPath(filePath) { return fileMap.get(filePath); } return getGitCommitDateFromPath; } /** * Gets the Git commit date from path. * * @param {string} filePath The file path * @returns {Date | undefined} Commit date if path is commited to Git, otherwise * `undefined` */ const getGitCommitDateFromPath = await initGetGitCommitDateFromPath(); export default getGitCommitDateFromPath;