From 0efe0a3cbce8d5481744987cef42c9fcea5f7834 Mon Sep 17 00:00:00 2001 From: alifeee Date: Thu, 25 Jan 2024 01:13:12 +0000 Subject: [PATCH] add fetch-depth note to `git last modified` and `git created` --- src/docs/dates.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/docs/dates.md b/src/docs/dates.md index e43eeb718f..7e88a3e253 100644 --- a/src/docs/dates.md +++ b/src/docs/dates.md @@ -34,8 +34,10 @@ Valid `date` values: * `Last Modified`: automatically resolves to the file’s last modified date * `Created`: automatically resolves to the file’s created date (default, this is what is used when `date` is omitted). * `git Last Modified`: {% addedin "1.0.1" %} automatically resolves to the file’s latest git commit. If a file is not yet checked in to git, it assigns `Date.now()` to `page.date` instead. + * This needs an entire git history (which is often not the case in CI environments) or it will return the date of checkout. Fetch the entire history in your CI, for example in GitHub by setting `fetch-depth: 0` with [GitHub's checkout action](https://github.com/actions/checkout). * This one is a bit resource intensive, so you may want to limit this to your CI server environment only using JavaScript data files and [Environment Variables](/docs/environment-vars/). Check out [this real-world directory data file](https://github.com/11ty/11ty-website/blob/5403f2b853e09165bec8bc6f7466a6a041487bcc/src/docs/docs.11tydata.js#L5-L7). * `git Created`: {% addedin "2.0.0-canary.13" %} automatically resolves to the file’s first git commit. It uses git's `--follow` flag to make a "best effort" renaming tracking. If a file is not yet checked in to git, it assigns `Date.now()` to `page.date` instead. + * This needs an entire git history (which is often not the case in CI environments) or it will return the date of checkout. Fetch the entire history in your CI, for example in GitHub by setting `fetch-depth: 0` with [GitHub's checkout action](https://github.com/actions/checkout). * This one is a bit resource intensive, so you may want to limit this to your CI server environment only using JavaScript data files and [Environment Variables](/docs/environment-vars/). Check out [this real-world directory data file](https://github.com/11ty/11ty-website/blob/5403f2b853e09165bec8bc6f7466a6a041487bcc/src/docs/docs.11tydata.js#L5-L7). * `2016-01-01` or any other valid [YAML date value](https://yaml.org/type/timestamp.html) (leaving off the time assumes midnight in UTC, or `00:00:00Z`) * `"2016-01-01"` or any other valid ISO 8601 **string** that [Luxon’s `DateTime.fromISO`](https://moment.github.io/luxon/#/parsing?id=iso-8601) can parse (see also the [Luxon API docs](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso)).