From 2b0badd207df4d31c2bd833dcbba84c4eb38be99 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 3 Feb 2025 09:43:48 +0100 Subject: [PATCH] Fix sitemap date Also: - bump to node 22 - use `netlify-plugin-cache` --- .nvmrc | 2 +- _config/filters.js | 4 ++-- content/sitemap.xml.njk | 2 +- netlify.toml | 6 ++++++ package.json | 4 +++- yarn.lock | 5 +++++ 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.nvmrc b/.nvmrc index 209e3ef..2bd5a0a 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20 +22 diff --git a/_config/filters.js b/_config/filters.js index b347929..16e34c1 100644 --- a/_config/filters.js +++ b/_config/filters.js @@ -15,8 +15,8 @@ export default function (eleventyConfig) { return dayjs(dateObj).locale('fr').format('D MMMM YYYY'); }); - eleventyConfig.addFilter('htmlDateString', (dateObj) => { - return dayjs(dateObj).format('YYYY-MM-D'); + eleventyConfig.addFilter('sitemapDate', (dateObj) => { + return dayjs(dateObj).format('YYYY-MM-DD'); }); // Get the first `n` elements of a collection. diff --git a/content/sitemap.xml.njk b/content/sitemap.xml.njk index 7a8e823..3cf566d 100644 --- a/content/sitemap.xml.njk +++ b/content/sitemap.xml.njk @@ -9,7 +9,7 @@ eleventyExcludeFromCollections: true {% set absoluteUrl %}{{ page.url | htmlBaseUrl(metadata.url) }}{% endset %} {{ absoluteUrl }} - {{ page.date | htmlDateString }} + {{ page.date | sitemapDate }} {%- endfor %} diff --git a/netlify.toml b/netlify.toml index 290d8ce..ce48f9d 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,9 @@ [build] publish = "_site" command = "yarn build" + +[[plugins]] +package = "netlify-plugin-cache" + + [plugins.inputs] + paths = [ ".cache" ] diff --git a/package.json b/package.json index 673119f..272beca 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,7 @@ "zod": "^3.23.8", "zod-validation-error": "^3.3.1" }, - "dependencies": {} + "dependencies": { + "netlify-plugin-cache": "^1.0.3" + } } diff --git a/yarn.lock b/yarn.lock index 85dafc3..0ea4edb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1255,6 +1255,11 @@ ms@2.1.3, ms@^2.1.3: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +netlify-plugin-cache@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/netlify-plugin-cache/-/netlify-plugin-cache-1.0.3.tgz#f60514e259dff2b3286b6d60b570bb1c81206794" + integrity sha512-CTOwNWrTOP59T6y6unxQNnp1WX702v2R/faR5peSH94ebrYfyY4zT5IsRcIiHKq57jXeyCrhy0GLuTN8ktzuQg== + node-retrieve-globals@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/node-retrieve-globals/-/node-retrieve-globals-6.0.0.tgz#682889351b83fb7b6c48d0e09b16a0487ff3ee1f"