main rss feed combines posts and recipes

This commit is contained in:
Joshua Seigler 2025-07-03 01:07:32 -04:00
parent 0dde8aff3d
commit 02732645da
3 changed files with 10 additions and 9 deletions

View file

@ -8,7 +8,6 @@ import mdLinkAttributes from "markdown-it-link-attributes"
import mdPrism from "markdown-it-prism" import mdPrism from "markdown-it-prism"
import dayjs from "dayjs" import dayjs from "dayjs"
import utc from "dayjs/plugin/utc.js" import utc from "dayjs/plugin/utc.js"
import site from "./site/_data/site.js"
import clean from "eleventy-plugin-clean" import clean from "eleventy-plugin-clean"
import toc from "eleventy-plugin-toc" import toc from "eleventy-plugin-toc"
import EleventyFeedPlugin from "@11ty/eleventy-plugin-rss" import EleventyFeedPlugin from "@11ty/eleventy-plugin-rss"
@ -114,6 +113,12 @@ export default async (config) => {
config.addCollection("links", fetchShaarliWebroll) config.addCollection("links", fetchShaarliWebroll)
config.addCollection("combinedFeed", (collectionApi) => {
return collectionApi.getAllSorted().filter(item => {
return (item.data.tags ?? []).some(t => ['posts', 'recipes', 'links'].includes(t))
})
})
config.addFilter("toISOString", (dateString) => { config.addFilter("toISOString", (dateString) => {
return new Date(dateString).toISOString() return new Date(dateString).toISOString()
}) })

View file

@ -4,13 +4,9 @@ eleventyComputed:
tag: "{{ page.fileSlug }}" tag: "{{ page.fileSlug }}"
title: "{{ tag | capitalize }}" title: "{{ tag | capitalize }}"
rssUrl: " rssUrl: "
{%- if tag == 'posts' -%}
/feed.xml
{%- else -%}
{%- if tag != 'music' -%} {%- if tag != 'music' -%}
/feeds/{{tag}} /feeds/{{tag}}.xml
{%- endif -%} {%- endif -%}
{%- endif -%}
" "
--- ---

View file

@ -10,13 +10,13 @@ pagination:
- links - links
- timeline - timeline
eleventyComputed: eleventyComputed:
finalLink: "{% if tag == 'posts' %}feed.xml{% else %}feeds/{{tag | slugify}}.xml{% endif %}" finalLink: "{% if tag == 'combinedFeed' %}feed.xml{% else %}feeds/{{tag | slugify}}.xml{% endif %}"
permalink: "/assets/{{finalLink}}" permalink: "/assets/{{finalLink}}"
--- ---
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="/simple-atom.xslt"?> <?xml-stylesheet type="text/xsl" href="/simple-atom.xslt"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ site.language }}"> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ site.language }}">
<title>{{ site.title }} - {{ tag }}</title> <title>{{ site.title }}{% if tag !== 'combinedFeed' %} - {{ tag }}{% endif %}</title>
<subtitle>{{ collections.pages[tag].data.description or site.description }}</subtitle> <subtitle>{{ collections.pages[tag].data.description or site.description }}</subtitle>
<link href="{{ site.baseUrl }}{{ finalLink }}" rel="self" /> <link href="{{ site.baseUrl }}{{ finalLink }}" rel="self" />
<link href="{{ site.baseUrl | addPathPrefixToFullUrl }}" /> <link href="{{ site.baseUrl | addPathPrefixToFullUrl }}" />
@ -29,7 +29,7 @@ eleventyComputed:
{%- if entry.url and entry.date -%} {%- if entry.url and entry.date -%}
{%- set absolutePostUrl %}{{ entry.url | htmlBaseUrl(site.baseUrl) }}{% endset %} {%- set absolutePostUrl %}{{ entry.url | htmlBaseUrl(site.baseUrl) }}{% endset %}
<entry> <entry>
<title>{{ entry.data.title }}</title> <title>{% if tag == 'combinedFeed' %}{{ entry.data.tags[0].slice(0,-1) | title }}: {% endif %}{{ entry.data.title }}</title>
<link href="{{ absolutePostUrl }}" /> <link href="{{ absolutePostUrl }}" />
<updated>{{ entry.date | dateToRfc3339 }}</updated> <updated>{{ entry.date | dateToRfc3339 }}</updated>
<id>{{ absolutePostUrl }}</id> <id>{{ absolutePostUrl }}</id>