Add frontmatter data for exclusing an item from sitemap

This commit is contained in:
Leilukin 2025-05-03 20:16:51 +08:00
parent eeedd5d657
commit b2ac457511
5 changed files with 25 additions and 16 deletions

View File

@ -1,9 +1,10 @@
export default {
tags: ["changelogs", "feed items"],
permalink: false,
excludeFromSitemap: true,
eleventyComputed: {
title: function(data) {
return `Changelog: ${this.formatDate(data.date)}`;
}
}
}
}

View File

@ -1,15 +0,0 @@
---
permalink: "{{ page.filePathStem }}"
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{%- for item in collections.all %}
<url>
<loc>{{ sitemeta.siteUrl + item.url }}</loc>
<lastmod>{% if item.updated %}{{ item.updated.toISOString() }}{% else %}{{ item.date.toISOString() }}{% endif %}</lastmod>
<changefreq>{{ item.data.sitemap.changefreq | default("weekly") }}</changefreq>
<priority>{{ item.data.sitemap.priority | default(0.5) }}</priority>
</url>
{%- endfor %}
</urlset>

17
src/sitemap.xml.vto Normal file
View File

@ -0,0 +1,17 @@
---
permalink: "{{ page.filePathStem }}"
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{{ for item of collections.all }}
{{ if !item.data.excludeFromSitemap }}
<url>
<loc>{{ sitemeta.siteUrl + item.url }}</loc>
<lastmod>{{ item.updated ? item.updated.toISOString() : item.date.toISOString() }}</lastmod>
<changefreq>{{ item.data.sitemap.changefreq }}</changefreq>
<priority>{{ item.data.sitemap.priority }}</priority>
</url>
{{ /if }}
{{ /for }}
</urlset>

6
src/src.11tydata.js Normal file
View File

@ -0,0 +1,6 @@
export default {
sitemap: {
changefreq: "weekly",
priority: 0.5,
}
}