diff --git a/_11ty/api/allFeeds.js b/_11ty/api/allFeeds.js index 5618f50..1c1e1e4 100644 --- a/_11ty/api/allFeeds.js +++ b/_11ty/api/allFeeds.js @@ -1,11 +1,11 @@ const fetchJsonFeeds = require("./jsonFeeds"); -const fetchXmlFeeds = require("./xmlFeeds"); +const fetchRssFeeds = require("./rssFeeds"); module.exports = async () => { - const xmlFeeds = await fetchXmlFeeds(); + const rssFeeds = await fetchRssFeeds(); const jsonFeeds = await fetchJsonFeeds(); - const allFeeds = [...xmlFeeds, ...jsonFeeds] + const allFeeds = [...rssFeeds, ...jsonFeeds] .sort((a, b) => a.name.localeCompare(b.name)) .filter((item) => item); diff --git a/_11ty/api/jsonFeeds.js b/_11ty/api/jsonFeeds.js index 309a37d..161a861 100644 --- a/_11ty/api/jsonFeeds.js +++ b/_11ty/api/jsonFeeds.js @@ -32,8 +32,6 @@ module.exports = async () => { .sort((a, b) => new Date(b.published) - new Date(a.published)) .slice(0, siteConfig.maxItemsPerFeed); - // TODO: Validate article items - return { ...site, articles, diff --git a/_11ty/api/xmlFeeds.js b/_11ty/api/rssFeeds.js similarity index 89% rename from _11ty/api/xmlFeeds.js rename to _11ty/api/rssFeeds.js index 13c7297..3b3dcba 100644 --- a/_11ty/api/xmlFeeds.js +++ b/_11ty/api/rssFeeds.js @@ -8,10 +8,10 @@ const siteConfig = require("../../content/_data/siteConfig"); const stripAndTruncateHTML = require("../helpers/stripAndTruncateHTML"); module.exports = async () => { - const xmlFeedSites = siteMetadata().filter((site) => site.feedType === "xml"); + const rssFeedSites = siteMetadata().filter((site) => site.feedType === "rss"); const { extractFromXml } = await feedExtractor; - const feedContents = await xmlFeedSites.map(async (site) => { + const feedContents = await rssFeedSites.map(async (site) => { try { const feedData = await EleventyFetch(site.feed, { ...ELEVENTY_FETCH_OPTIONS, @@ -20,8 +20,6 @@ module.exports = async () => { const { entries } = extractFromXml(feedData); - // TODO: Validate article items - const articles = entries .map((item) => ({ title: item.title || siteConfig.defaultArticleTitle, diff --git a/_11ty/constants.js b/_11ty/constants.js index 8ebb87a..5b3ace7 100644 --- a/_11ty/constants.js +++ b/_11ty/constants.js @@ -2,8 +2,8 @@ const path = require("path"); const siteConfig = require("../content/_data/siteConfig"); module.exports = { - DEFAULT_FEED_TYPE: "xml", - ALLOWED_FEED_TYPES: ["xml", "json"], + DEFAULT_FEED_TYPE: "rss", + ALLOWED_FEED_TYPES: ["rss", "json"], SITES_DIRECTORY: path.join("content", "sites"), ALLOWED_SITE_PROPERTIES: [ "file", diff --git a/content/_data/phrases.js b/content/_data/phrases.js index 38df3fe..ad3f6c3 100644 --- a/content/_data/phrases.js +++ b/content/_data/phrases.js @@ -7,6 +7,7 @@ module.exports = { sAvatar: "'s avatar", newerArticles: "Newer", olderArticles: "Older", + opmlFileTitle: "All feeds", menu: { sites: "Sites", about: "About", diff --git a/content/pages/sites.md b/content/pages/sites.md index f147581..9d39b15 100644 --- a/content/pages/sites.md +++ b/content/pages/sites.md @@ -8,4 +8,6 @@ canonical: /sites/ This is a list of sites aggregated on this Multiplicity instance. Modify it by adding / editing Markdown files in `content/sites` directory. +[Download OPML file](/feeds.opml) + {% include "partials/sitelist.njk" %} diff --git a/content/utils/opml.njk b/content/utils/opml.njk new file mode 100644 index 0000000..8c4f593 --- /dev/null +++ b/content/utils/opml.njk @@ -0,0 +1,15 @@ +--- +permalink: /feeds.opml +eleventyExcludeFromCollections: true +--- + + + + {{ phrases.opmlFileTitle }} + + + {%- for site in sites %} + + {%- endfor %} + + \ No newline at end of file