diff --git a/content/feed/.virtual b/content/feed/.virtual new file mode 100644 index 0000000..0ee5e54 --- /dev/null +++ b/content/feed/.virtual @@ -0,0 +1 @@ +For RSS feed, Atom Feed, and JSON feed templates, see the plugin in eleventy.config.js diff --git a/content/feed/atom.njk b/content/feed/atom.njk deleted file mode 100755 index d8f8688..0000000 --- a/content/feed/atom.njk +++ /dev/null @@ -1,31 +0,0 @@ ---- -# Metadata comes from _data/metadata.js -permalink: /feed/feed.xml -eleventyNavigation: - key: Feed - order: 3 ---- - - - - {{ metadata.title }} - {{ metadata.description }} - - - {{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }} - {{ metadata.url }} - - {{ metadata.author.name }} - {{ metadata.author.email }} - - {%- for post in collections.posts | reverse %} - {%- set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.url) }}{% endset %} - - {{ post.data.title }} - - {{ post.date | dateToRfc3339 }} - {{ absolutePostUrl }} - {{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) }} - - {%- endfor %} - diff --git a/content/feed/feed.11tydata.js b/content/feed/feed.11tydata.js deleted file mode 100644 index 3c76e38..0000000 --- a/content/feed/feed.11tydata.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - layout: false, -}; diff --git a/content/feed/json.njk b/content/feed/json.njk deleted file mode 100644 index 3b33b59..0000000 --- a/content/feed/json.njk +++ /dev/null @@ -1,29 +0,0 @@ ---- -# Metadata comes from _data/metadata.js -permalink: /feed/feed.json ---- -{ - "version": "https://jsonfeed.org/version/1.1", - "title": "{{ metadata.title }}", - "language": "{{ metadata.language }}", - "home_page_url": "{{ metadata.url | addPathPrefixToFullUrl }}", - "feed_url": "{{ permalink | htmlBaseUrl(metadata.url) }}", - "description": "{{ metadata.description }}", - "author": { - "name": "{{ metadata.author.name }}", - "url": "{{ metadata.author.url }}" - }, - "items": [ - {%- for post in collections.posts | reverse %} - {%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.url) %} - { - "id": "{{ absolutePostUrl }}", - "url": "{{ absolutePostUrl }}", - "title": "{{ post.data.title }}", - "content_html": {% if post.templateContent %}{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }}{% else %}""{% endif %}, - "date_published": "{{ post.date | dateToRfc3339 }}" - } - {% if not loop.last %},{% endif %} - {%- endfor %} - ] -} diff --git a/eleventy.config.js b/eleventy.config.js index b0b94ef..72bcb31 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,7 +1,7 @@ import markdownItAnchor from "markdown-it-anchor"; import { InputPathToUrlTransformPlugin, HtmlBasePlugin } from "@11ty/eleventy"; -import pluginRss from "@11ty/eleventy-plugin-rss"; +import { feedPlugin } from "@11ty/eleventy-plugin-rss"; import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight"; import pluginNavigation from "@11ty/eleventy-navigation"; import { eleventyImageTransformPlugin } from "@11ty/eleventy-img"; @@ -32,7 +32,37 @@ export default async function(eleventyConfig) { // eleventyConfig.addBundle("js"); // Official plugins - eleventyConfig.addPlugin(pluginRss); + eleventyConfig.addPlugin(feedPlugin, { + files: { + json: "/feed/feed.json", + atom: "/feed/feed.xml", + // "rss": "/feed/rss.xml", + }, + stylesheet: { + atom: "pretty-atom-feed.xsl", + }, + templateData: { + atom: { + eleventyNavigation: { + key: "Feed", + order: 3 + } + } + }, + collectionName: "posts", + limit: 10, + metadata: { + language: "en", + title: "Blog Title", + subtitle: "This is a longer description about your blog.", + base: "https://example.com/", + author: { + name: "Your Name", + email: "me@example.com" + } + } + }); + eleventyConfig.addPlugin(pluginSyntaxHighlight, { preAttributes: { tabindex: 0 } }); @@ -44,9 +74,12 @@ export default async function(eleventyConfig) { eleventyConfig.addPlugin(eleventyImageTransformPlugin, { // File extensions to process in _site folder extensions: "html", + // Output formats for each image. formats: ["avif", "webp", "auto"], + // widths: ["auto"], + defaultAttributes: { // e.g. assigned on the HTML tag will override these values. loading: "lazy", @@ -92,6 +125,7 @@ export const config = { "njk", "html", "liquid", + "11ty.js", ], // Pre-process *.md files with: (default: `liquid`) diff --git a/package.json b/package.json index afb8caf..70f369e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@11ty/eleventy": "3.0.0-alpha.10", "@11ty/eleventy-img": "5.0.0-beta.1", "@11ty/eleventy-navigation": "^0.3.5", - "@11ty/eleventy-plugin-rss": "^1.2.0", + "@11ty/eleventy-plugin-rss": "^2.0.0-beta.5", "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0", "luxon": "^3.4.4", "markdown-it-anchor": "^8.6.7",