From 155cd84d776f722380a4bdbe90555c0fb3e112df Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 26 Dec 2020 11:51:25 -0300 Subject: sitemap.xml: Simplify generation of sitemap.xml, include all collections --- _config.yml | 9 ++++++++ sitemap.xml | 70 +++++++++++++++++++------------------------------------------ 2 files changed, 30 insertions(+), 49 deletions(-) diff --git a/_config.yml b/_config.yml index afdea8b..bf0220f 100644 --- a/_config.yml +++ b/_config.yml @@ -62,6 +62,15 @@ collections: output: true permalink: /screencast/:year/:month/:title:output_ext +all_collections: + - pages + - articles + - tils + - pastebins + - slides + - podcasts + - screencasts + t: description: en: "EuAndreh's website" diff --git a/sitemap.xml b/sitemap.xml index 050bdb4..2104d39 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,57 +2,29 @@ --- - {% for post in site.posts %} - - {{ site.url }}{{ post.url }} - {% assign versions=site.posts | where:"ref", post.ref %} - {% for version in versions %} - - {% endfor %} - {{ post.date | date_to_xmlschema }} - monthly - - {% endfor %} - - {% for page in site.pages %} - - {{ site.url }}{{ page.url }} + {% for coll in site.all_collections %} + {% for page in site[coll] %} + {% comment %} + page ref is nil for generated pages, such + as post.html.1.txt code snippets + {% endcomment %} {% if page.ref != nil %} - {% assign versions=site.pages | where:"ref", page.ref %} - {% for version in versions %} - - {% endfor %} + + {{ site.url }}{{ page.url }} + {% assign ref=page.ref %} + {% if page.ref == 'root' %} + {% assign ref='index' %} + {% endif %} + {% assign versions=site[coll] | where:"ref", ref %} + {% for version in versions %} + + {% endfor %} + {% if page.date != nil %} + {{ page.updated_at | default: page.date | date_to_xmlschema }} + {% endif %} + monthly + {% endif %} - monthly - - {% endfor %} - - {% for pastebin in site.pastebins %} - - {{ site.url }}{{ pastebin.url }} - yearly - - {% endfor %} - - {% for til in site.tils %} - - {{ site.url }}{{ til.url }} - {% assign versions=site.tils | where:"ref", til.ref %} - {% for version in versions %} - - {% endfor %} - monthly - - {% endfor %} - - {% for slide in site.slides %} - - {{ site.url }}{{ slide.url }} - {% assign versions=site.slides | where:"ref", slide.ref %} - {% for version in versions %} - {% endfor %} - monthly - {% endfor %} -- cgit v1.2.3