From 048949ea31feb92dc8a80c78dfaef4ed4a8e6142 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Sun, 11 Aug 2019 20:32:11 +1000 Subject: [PATCH] Rename last_build_date to latest_date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable name matched the RSS tag it ended up in, but was misleading about what it actually was—because if you actually want “last build date”, you should use `now()`. (Due to the potential for edits, I think that either there should be an official `updated` field on pages, or that these templates should use `now()`.) --- CHANGELOG.md | 1 + components/site/src/lib.rs | 2 +- components/templates/src/builtins/atom.xml | 2 +- components/templates/src/builtins/rss.xml | 2 +- docs/content/documentation/templates/feeds.md | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20885a05..1e66120c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Config value `rss_limit` is renamed to `feed_limit` - Config value `languages.*.rss` is renamed to `languages.*.feed` - Config value `generate_rss` is renamed to `generate_feed` + - Feed template variable `last_build_date` is renamed to `latest_date` Users with existing feeds should either set `feed_filename = "rss.xml"` in config.toml to keep things the same, or set up a 3xx redirect from rss.xml to atom.xml so that existing feed consumers aren’t broken. diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 0ef6615b..88c8c0a9 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -1065,7 +1065,7 @@ impl Site { pages.par_sort_unstable_by(sort_actual_pages_by_date); - context.insert("last_build_date", &pages[0].meta.date.clone()); + context.insert("latest_date", &pages[0].meta.date.clone()); let library = self.library.read().unwrap(); // limit to the last n elements if the limit is set; otherwise use all. let num_entries = self.config.feed_limit.unwrap_or_else(|| pages.len()); diff --git a/components/templates/src/builtins/atom.xml b/components/templates/src/builtins/atom.xml index 17f5fe41..dcbe7507 100644 --- a/components/templates/src/builtins/atom.xml +++ b/components/templates/src/builtins/atom.xml @@ -5,7 +5,7 @@ Zola - {{ last_build_date | date(format="%+") }} + {{ latest_date | date(format="%+") }} {{ feed_url | safe }} {%- for page in pages %} Zola {{ config.default_language }} - {{ last_build_date | date(format="%a, %d %b %Y %H:%M:%S %z") }} + {{ latest_date | date(format="%a, %d %b %Y %H:%M:%S %z") }} {%- for page in pages %} {{ page.title }} diff --git a/docs/content/documentation/templates/feeds.md b/docs/content/documentation/templates/feeds.md index b013b514..71fd7c1d 100644 --- a/docs/content/documentation/templates/feeds.md +++ b/docs/content/documentation/templates/feeds.md @@ -20,6 +20,6 @@ need to provide a template yourself. The feed template gets three variables in addition to `config`: - `feed_url`: the full url to that specific feed -- `last_build_date`: the date of the latest post +- `latest_date`: the date of the latest post - `pages`: see [page variables](@/documentation/templates/pages-sections.md#page-variables) for a detailed description of what this contains