From 37e68c24fb4b24db9360086efba56f54ea565191 Mon Sep 17 00:00:00 2001 From: Jim Bumgardner Date: Fri, 9 Aug 2024 16:43:51 -0700 Subject: [PATCH] Fixed sitemap to exclude pages with do-not-crawl tag. Fixed such pages to include correct robots directive. --- pages/_data/eleventyComputed.js | 6 ++---- pages/manual-content/sitemap.njk | 14 +++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pages/_data/eleventyComputed.js b/pages/_data/eleventyComputed.js index ff378728..b39523ad 100644 --- a/pages/_data/eleventyComputed.js +++ b/pages/_data/eleventyComputed.js @@ -182,17 +182,15 @@ module.exports = async () => { if (!perfAudits) { perfAudits = await fetch(perfApiUrl).then((res) => res.json()); } - return { title: (article) => article?.data?.title || article.title, id: (article) => article?.data?.id, date: (article) => article?.data?.date || article.date, - publishdate: (article) => - article?.data?.date.split("T")[0] || article.publishdate, + publishdate: (article) => article?.data?.date.split("T")[0] || article.publishdate, meta: (article) => article?.data?.excerpt || article.meta, description: (article) => article?.data?.excerpt || article.meta, author: (article) => article?.data?.author || article.author, - tags: (article) => (isPost(article) ? ["news"] : article.tags), + tags: (article) => article?.data?.tags || (isPost(article) ? ["news"] : article.tags), permalink: (article) => getPermalink(article), layout: (article) => getLayout(article), eleventyNavigation: (article) => getNavigation(article), diff --git a/pages/manual-content/sitemap.njk b/pages/manual-content/sitemap.njk index 50542911..4270a9b4 100644 --- a/pages/manual-content/sitemap.njk +++ b/pages/manual-content/sitemap.njk @@ -5,12 +5,12 @@ eleventyExcludeFromCollections: true {% for page in collections.all %} - {% if not sitemap.urls[page.url | url ].exclude %} - - https://innovation.ca.gov{{ page.url | url }} - {{ page.date.toISOString() }} - daily - - {% endif %} + {% if (page.data.tags and not page.data.tags.includes('do-not-crawl')) and not sitemap.urls[page.url | url ].exclude %} + + https://innovation.ca.gov{{ page.url | url }} + {{ page.date.toISOString() }} + daily + + {% endif %} {% endfor %} \ No newline at end of file