add sitemaps

pull/1/head
maia arson crimew 2023-01-21 18:21:09 +01:00
parent 5a14b22e73
commit 3ef92f11bb
11 changed files with 434 additions and 2637 deletions

View File

@ -1,5 +1,5 @@
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
const pluginRss = require('@11ty/eleventy-plugin-rss')
const pluginRss = require('@11ty/eleventy-plugin-rss');
module.exports = function (eleventyConfig) {
const parseDate = (str) => {
@ -18,7 +18,9 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy({ "src/static": "/" });
eleventyConfig.addFilter("date_to_datetime", (obj) => {
console.log(obj);
const date = parseDate(obj);
console.log(date);
return date.toISOString();
});
@ -32,6 +34,10 @@ module.exports = function (eleventyConfig) {
return `${month} ${day}, ${year}`;
});
eleventyConfig.addFilter('urlescape', str => {
return str.split('/').map(part => encodeURI(part)).join('/')
})
eleventyConfig.addCollection('posts', collection => {
return collection.getFilteredByGlob('src/posts/*.md').reverse()
})

3021
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
"update": "git pull && npm run build"
},
"dependencies": {
"@11ty/eleventy": "^1.0.1",
"@11ty/eleventy": "^v2.0.0-beta.1",
"@11ty/eleventy-plugin-rss": "^1.2.0",
"@11ty/eleventy-plugin-syntaxhighlight": "^4.0.0"
}

View File

@ -16,7 +16,7 @@
{% if feature_alt %}<meta property="og:image:alt" content="{{ feature_alt }}">{% endif %}
<meta property="og:site_name" content="{{ site.title }}">
<meta name="article:author" content="{{ site.name }}">
{% if date %}<meta name="article:published_time" content="{{ date | date_to_datetime }}">{% endif %}
{% if page.date %}<meta name="article:published_time" content="{{ page.date | date_to_datetime }}">{% endif %}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="{{ site.twitter }}">
<meta name="twitter:creator" content="{{ site.twitter }}">

View File

@ -1,5 +1,6 @@
---
permalink: /index.html
date: git Last Modified
---
{% extends 'layouts/default.njk' %}
{% block main %}

View File

@ -12,7 +12,7 @@ permalink: /posts/{% if pagination.pageNumber > 0 %}page/{{ pagination.pageNumbe
<ul>
{% for entry in pagination.items %}
<li>
<span><a href="{{ entry.url }}">{{ entry.data.title }}</a> on <span><time datetime="{{ entry.data.date | date_to_datetime }}">{{ entry.data.date | date_formatted }}</time></span></span>
<span><a href="{{ entry.url }}">{{ entry.data.title }}</a> on <span><time datetime="{{ entry.page.date | date_to_datetime }}">{{ entry.page.date | date_formatted }}</time></span></span>
</li>
{% endfor %}
</ul>

View File

@ -2,6 +2,7 @@
title: maia sample packs :3
subhead: sample packs
permalink: /samples/index.html
date: git Last Modified
---
{% extends 'layouts/default.njk' %}
{% block main %}

19
src/sitemap-news.njk Normal file
View File

@ -0,0 +1,19 @@
---
permalink: /sitemap-news.xml
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
{% for entry in collections.posts %}
<url>
<loc>{{ site.url }}{{ entry.url | urlescape }}</loc>{% if "hidden" not in entry.data.tags %}
{% if entry.data.changed_date or entry.page.date %}<lastmod>{% if entry.data.changed_date %}{{ entry.data.changed_date | date_to_datetime }}{% else %}{{ entry.page.date | date_to_datetime }}{% endif %}</lastmod>{% endif %}
<news:news>
<news:publication>
<news:name>{{ site.title }}</news:name>
<news:language>{{ site.language }}</news:language>
</news:publication>
<news:publication_date>{{ entry.page.date | date_to_datetime }}</news:publication_date>
<news:title>{{ entry.data.title }}</news:title>
</news:news>
</url>{% endif %}{% endfor %}
</urlset>

11
src/sitemap.njk Normal file
View File

@ -0,0 +1,11 @@
---
permalink: /sitemap.xml
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for entry in collections.all %}{% if "sitemap" not in entry.url and "robots.txt" not in entry.url and (not entry.data.tags or "hidden" not in entry.data.tags) %}
<url>
<loc>{{ site.url }}{{ entry.url | urlescape }}</loc>
{% if entry.data.changed_date or entry.page.date %}<lastmod>{% if entry.data.changed_date %}{{ entry.data.changed_date | date_to_datetime }}{% else %}{{ entry.page.date | date_to_datetime }}{% endif %}</lastmod>{% endif %}
</url>{% endif %}{% endfor %}
</urlset>

View File

@ -10,6 +10,7 @@ pagination:
- posts
addAllPagesToCollections: true
permalink: /posts/tagged/{{ tag | slugify }}/index.html
date: git Last Modified
---
{% extends 'layouts/default.njk' %}
{% block main %}
@ -20,7 +21,7 @@ permalink: /posts/tagged/{{ tag | slugify }}/index.html
{% set taglist = collections[ tag ] %}
{% for entry in taglist | reverse %}
<li>
<span><a href="{{ entry.url }}">{{ entry.data.title }}</a> on <span><time datetime="{{ entry.date | date_to_datetime }}">{{ entry.date | date_formatted }}</time></span></span>
<span><a href="{{ entry.url }}">{{ entry.data.title }}</a> on <span><time datetime="{{ entry.page.date | date_to_datetime }}">{{ entry.page.date | date_formatted }}</time></span></span>
</li>
{% endfor %}
</ul>

View File

@ -1,5 +1,6 @@
---
permalink: /whoami.json
date: git Last Modified
---
{
"name": "{{ site.name }}",