Update feed display

This commit is contained in:
2024-11-12 00:11:03 +00:00
parent 8adccc6f95
commit 0a2082a4dc
4 changed files with 41 additions and 139 deletions

View File

@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title or metadata.title }}</title> <title>{{ title or metadata.title }}</title>
<meta name="description" content="{{ description or metadata.description }}"> <meta name="description" content="{{ description or metadata.description }}">
<link rel="alternate" href="feed/feed.xml" type="application/atom+xml" title="{{ metadata.title }}"> <link rel="alternate" href="/feed/feed.xml" type="application/atom+xml" title="{{ metadata.title }}">
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png?v=2"> <link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png?v=2">
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png?v=2"> <link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png?v=2">

View File

@@ -1 +0,0 @@
For RSS feed, Atom Feed, and JSON feed templates, see the plugin in eleventy.config.js

File diff suppressed because one or more lines are too long

View File

@@ -2,19 +2,19 @@ import {
IdAttributePlugin, IdAttributePlugin,
InputPathToUrlTransformPlugin, InputPathToUrlTransformPlugin,
HtmlBasePlugin HtmlBasePlugin
} from "@11ty/eleventy"; } from '@11ty/eleventy';
import { feedPlugin } from "@11ty/eleventy-plugin-rss"; import { feedPlugin } from '@11ty/eleventy-plugin-rss';
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight"; import pluginSyntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight';
import pluginNavigation from "@11ty/eleventy-navigation"; import pluginNavigation from '@11ty/eleventy-navigation';
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img"; import { eleventyImageTransformPlugin } from '@11ty/eleventy-img';
import pluginFilters from "./_config/filters.js"; import pluginFilters from './_config/filters.js';
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */ /** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
export default async function (eleventyConfig) { export default async function (eleventyConfig) {
// Drafts, see also _data/eleventyDataSchema.js // Drafts, see also _data/eleventyDataSchema.js
eleventyConfig.addPreprocessor("drafts", "*", (data, content) => { eleventyConfig.addPreprocessor('drafts', '*', (data, content) => {
if (data.draft && process.env.ELEVENTY_RUN_MODE === "build") { if (data.draft && process.env.ELEVENTY_RUN_MODE === 'build') {
return false; return false;
} }
}); });
@@ -23,31 +23,30 @@ export default async function (eleventyConfig) {
// For example, `./public/css/` ends up in `_site/css/` // For example, `./public/css/` ends up in `_site/css/`
eleventyConfig eleventyConfig
.addPassthroughCopy({ .addPassthroughCopy({
"./public/": "/" './public/': '/'
}) })
.addPassthroughCopy("./content/feed/pretty-atom-feed.xsl") .addPassthroughCopy('./content/blog/**/images/*');
.addPassthroughCopy("./content/blog/**/images/*");
// Run Eleventy when these files change: // Run Eleventy when these files change:
// https://www.11ty.dev/docs/watch-serve/#add-your-own-watch-targets // https://www.11ty.dev/docs/watch-serve/#add-your-own-watch-targets
// Watch content images for the image pipeline. // Watch content images for the image pipeline.
eleventyConfig.addWatchTarget("content/blog/**/*.md"); eleventyConfig.addWatchTarget('content/blog/**/*.md');
eleventyConfig.addWatchTarget("content/blog/**/*.{svg,webp,png,jpeg}"); eleventyConfig.addWatchTarget('content/blog/**/*.{svg,webp,png,jpeg}');
// Per-page bundles, see https://github.com/11ty/eleventy-plugin-bundle // Per-page bundles, see https://github.com/11ty/eleventy-plugin-bundle
// Adds the {% css %} paired shortcode // Adds the {% css %} paired shortcode
eleventyConfig.addBundle("css", { eleventyConfig.addBundle('css', {
toFileDirectory: "dist" toFileDirectory: 'dist'
}); });
// Adds the {% js %} paired shortcode // Adds the {% js %} paired shortcode
eleventyConfig.addBundle("js", { eleventyConfig.addBundle('js', {
toFileDirectory: "dist" toFileDirectory: 'dist'
}); });
eleventyConfig.setFrontMatterParsingOptions({ eleventyConfig.setFrontMatterParsingOptions({
excerpt: true, excerpt: true,
excerpt_separator: "<!-- excerpt -->" excerpt_separator: '<!-- excerpt -->'
}); });
// Official plugins // Official plugins
@@ -59,26 +58,19 @@ export default async function (eleventyConfig) {
eleventyConfig.addPlugin(InputPathToUrlTransformPlugin); eleventyConfig.addPlugin(InputPathToUrlTransformPlugin);
eleventyConfig.addPlugin(feedPlugin, { eleventyConfig.addPlugin(feedPlugin, {
type: "atom", // or "rss", "json" type: 'atom',
outputPath: "/feed/feed.xml", outputPath: '/feed/feed.xml',
stylesheet: "pretty-atom-feed.xsl",
templateData: {
eleventyNavigation: {
key: "Feed",
order: 4
}
},
collection: { collection: {
name: "posts", name: 'posts',
limit: 10 limit: 10
}, },
metadata: { metadata: {
language: "en", language: 'en',
title: "Chris Kaczor", title: 'Chris Kaczor',
subtitle: "Code, Critters, and whatever I feel like writing about.", subtitle: 'Code, Critters, and whatever I feel like writing about.',
base: "https://chriskaczor.com/", base: 'https://chriskaczor.com/',
author: { author: {
name: "Chris Kaczor" name: 'Chris Kaczor'
} }
} }
}); });
@@ -86,17 +78,17 @@ export default async function (eleventyConfig) {
// Image optimization: https://www.11ty.dev/docs/plugins/image/#eleventy-transform // Image optimization: https://www.11ty.dev/docs/plugins/image/#eleventy-transform
eleventyConfig.addPlugin(eleventyImageTransformPlugin, { eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
// File extensions to process in _site folder // File extensions to process in _site folder
extensions: "html", extensions: 'html',
// Output formats for each image. // Output formats for each image.
formats: ["avif", "webp", "auto"], formats: ['avif', 'webp', 'auto'],
// widths: ["auto"], // widths: ["auto"],
defaultAttributes: { defaultAttributes: {
// e.g. <img loading decoding> assigned on the HTML tag will override these values. // e.g. <img loading decoding> assigned on the HTML tag will override these values.
loading: "lazy", loading: 'lazy',
decoding: "async" decoding: 'async'
} }
}); });
@@ -109,11 +101,11 @@ export default async function (eleventyConfig) {
// selector: "h1,h2,h3,h4,h5,h6", // default // selector: "h1,h2,h3,h4,h5,h6", // default
}); });
eleventyConfig.addShortcode("currentBuildDate", () => { eleventyConfig.addShortcode('currentBuildDate', () => {
return new Date().toISOString(); return new Date().toISOString();
}); });
eleventyConfig.amendLibrary("md", (mdLib) => { eleventyConfig.amendLibrary('md', (mdLib) => {
var defaultImageRender = mdLib.renderer.rules.image; var defaultImageRender = mdLib.renderer.rules.image;
mdLib.renderer.rules.image = function ( mdLib.renderer.rules.image = function (
@@ -124,7 +116,7 @@ export default async function (eleventyConfig) {
self self
) { ) {
const token = tokens[idx]; const token = tokens[idx];
const aIndex = token.attrIndex("src"); const aIndex = token.attrIndex('src');
const link = token.attrs[aIndex][1]; const link = token.attrs[aIndex][1];
if (/(http(s?)):\/\//i.test(link)) { if (/(http(s?)):\/\//i.test(link)) {
@@ -150,7 +142,7 @@ export default async function (eleventyConfig) {
self self
) { ) {
const token = tokens[idx]; const token = tokens[idx];
const aIndex = token.attrIndex("href"); const aIndex = token.attrIndex('href');
const link = token.attrs[aIndex][1]; const link = token.attrs[aIndex][1];
if (/(http(s?)):\/\//i.test(link)) { if (/(http(s?)):\/\//i.test(link)) {
@@ -175,20 +167,20 @@ export default async function (eleventyConfig) {
export const config = { export const config = {
// Control which files Eleventy will process // Control which files Eleventy will process
// e.g.: *.md, *.njk, *.html, *.liquid // e.g.: *.md, *.njk, *.html, *.liquid
templateFormats: ["md", "njk", "html", "liquid", "11ty.js"], templateFormats: ['md', 'njk', 'html', 'liquid', '11ty.js'],
// Pre-process *.md files with: (default: `liquid`) // Pre-process *.md files with: (default: `liquid`)
markdownTemplateEngine: "njk", markdownTemplateEngine: 'njk',
// Pre-process *.html files with: (default: `liquid`) // Pre-process *.html files with: (default: `liquid`)
htmlTemplateEngine: "njk", htmlTemplateEngine: 'njk',
// These are all optional: // These are all optional:
dir: { dir: {
input: "content", // default: "." input: 'content', // default: "."
includes: "../_includes", // default: "_includes" (`input` relative) includes: '../_includes', // default: "_includes" (`input` relative)
data: "../_data", // default: "_data" (`input` relative) data: '../_data', // default: "_data" (`input` relative)
output: "_site" output: '_site'
} }
// ----------------------------------------------------------------- // -----------------------------------------------------------------