1- export default function ( eleventyConfig ) {
1+ const pluginRss = require ( "@11ty/eleventy-plugin-rss" ) ;
2+ const pluginSyntaxHighlight = require ( "@11ty/eleventy-plugin-syntaxhighlight" ) ;
3+ const pluginNavigation = require ( "@11ty/eleventy-navigation" ) ;
4+ const markdownIt = require ( "markdown-it" ) ;
5+ const markdownItAnchor = require ( "markdown-it-anchor" ) ;
6+ const { DateTime } = require ( "luxon" ) ;
7+
8+ module . exports = function ( eleventyConfig ) {
9+
10+ // Add plugins
11+ eleventyConfig . addPlugin ( pluginRss ) ;
12+ eleventyConfig . addPlugin ( pluginSyntaxHighlight ) ;
13+ eleventyConfig . addPlugin ( pluginNavigation ) ;
14+
215 eleventyConfig . addPassthroughCopy ( "styles" ) ;
316
4- // Add shortcode for current year
5- eleventyConfig . addShortcode ( "year" , ( ) => `${ new Date ( ) . getFullYear ( ) } ` ) ;
17+ // Customize Markdown library and settings:
18+ let markdownLibrary = markdownIt ( {
19+ html : true ,
20+ breaks : true ,
21+ linkify : true ,
22+ } ) . use ( markdownItAnchor , {
23+ permalink : markdownItAnchor . permalink . ariaHidden ( {
24+ placement : "after" ,
25+ class : "direct-link" ,
26+ symbol : "#" ,
27+ level : [ 1 , 2 , 3 , 4 ] ,
28+ } ) ,
29+ slugify : eleventyConfig . getFilter ( "slug" ) ,
30+ } ) ;
31+ eleventyConfig . setLibrary ( "md" , markdownLibrary ) ;
32+
33+ eleventyConfig . addFilter ( "readableDate" , ( dateObj ) => {
34+ return DateTime . fromJSDate ( dateObj , { zone : "utc" } ) . toFormat (
35+ "dd LLL yyyy"
36+ ) ;
37+ } ) ;
38+
39+ // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
40+ eleventyConfig . addFilter ( "htmlDateString" , ( dateObj ) => {
41+ return DateTime . fromJSDate ( dateObj , { zone : "utc" } ) . toFormat ( "yyyy-LL-dd" ) ;
42+ } ) ;
643} ;
0 commit comments