1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 13:44:15 +00:00

Add hook to generate the lastmod of posts

This commit is contained in:
Cotes Chung
2020-11-19 01:58:35 +08:00
parent 1889b6b4e0
commit 10bc44367a
6 changed files with 43 additions and 57 deletions

View File

@@ -14,7 +14,11 @@ layout: compress
{% for post in site.posts %}
<url>
<loc>{{ site.url | append: site.baseurl | append: post.url }}</loc>
<lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
{% if post.lastmod %}
<lastmod>{{ post.lastmod | date_to_xmlschema }}</lastmod>
{% else %}
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
{% endif %}
{% if post.sitemap.changefreq %}
<changefreq>{{ post.sitemap.changefreq }}</changefreq>
@@ -59,19 +63,9 @@ layout: compress
{% continue %}
{% endif %}
{% capture lastmod %}
{% if page.lastmod %}
{{ page.lastmod }}
{% elsif page.date %}
{{ page.date }}
{% else %}
{{ site.time }}
{% endif %}
{% endcapture %}
<url>
<url>
<loc>{{ site.url | append: site.baseurl | append: page.url | remove: "index.html" }}</loc>
<lastmod>{{ lastmod | date_to_xmlschema }}</lastmod>
<lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
{% if page.sitemap.changefreq %}
<changefreq>{{ page.sitemap.changefreq }}</changefreq>
@@ -88,4 +82,4 @@ layout: compress
{% endfor %}
</urlset>
</urlset>