@@ -4,6 +4,13 @@ const pluginRss = require("@11ty/eleventy-plugin-rss");
44const Image = require ( "@11ty/eleventy-img" ) ;
55const htmlmin = require ( "html-minifier" ) ;
66const outdent = require ( "outdent" ) ;
7+ const pluginNavigation = require ( "@11ty/eleventy-navigation" ) ;
8+ const pluginSyntaxHighlight = require ( "@11ty/eleventy-plugin-syntaxhighlight" ) ;
9+ const markdownItAnchor = require ( "markdown-it-anchor" ) ;
10+ const markdownItAttrs = require ( "markdown-it-attrs" ) ;
11+ const pluginTOC = require ( "eleventy-plugin-toc" ) ;
12+ const pluginFilters = require ( "./_config/filters.js" ) ;
13+ const pluginShortCodes = require ( "./_config/shortcode.js" ) ;
714
815/** Maps a config of attribute-value pairs to an HTML string
916 * representing those same attribute-value pairs.
@@ -83,14 +90,61 @@ const imageShortcode = async (
8390module . exports = function ( eleventyConfig ) {
8491 // 11ty plugins
8592 eleventyConfig . addPlugin ( pluginRss ) ;
86- eleventyConfig . addPlugin ( Webmentions , {
87- domain : "benkutil.com" ,
88- token : process . env . WEBMENTIONS_TOKEN
93+
94+ // Only add Webmentions if token is provided
95+ if ( process . env . WEBMENTIONS_TOKEN ) {
96+ eleventyConfig . addPlugin ( Webmentions , {
97+ domain : "benkutil.com" ,
98+ token : process . env . WEBMENTIONS_TOKEN
99+ } ) ;
100+ }
101+
102+ eleventyConfig . addPlugin ( pluginNavigation ) ;
103+ eleventyConfig . addPlugin ( pluginSyntaxHighlight , {
104+ preAttributes : { tabindex : 0 }
105+ } ) ;
106+ eleventyConfig . addPlugin ( pluginTOC , {
107+ tags : [ 'h2' , 'h3' , 'h4' , 'h5' ] ,
108+ ul : true ,
109+ flat : false ,
110+ wrapper : 'div'
89111 } ) ;
90112
113+ // Add Tufte filters and shortcodes
114+ eleventyConfig . addPlugin ( pluginFilters ) ;
115+ eleventyConfig . addPlugin ( pluginShortCodes ) ;
116+
91117 // 11ty shortcodes
92118 eleventyConfig . addShortcode ( 'image' , imageShortcode ) ;
93119
120+ // Configure markdown-it
121+ const markdownIt = require ( "markdown-it" ) ;
122+ let options = {
123+ html : true ,
124+ breaks : true ,
125+ linkify : true ,
126+ typographer : true ,
127+ } ;
128+ let markdownLib = markdownIt ( options ) . use ( markdownItAttrs ) ;
129+ eleventyConfig . setLibrary ( "md" , markdownLib ) ;
130+
131+ eleventyConfig . amendLibrary ( "md" , mdLib => {
132+ mdLib . use ( markdownItAnchor , {
133+ permalink : markdownItAnchor . permalink . ariaHidden ( {
134+ placement : "after" ,
135+ class : "header-anchor" ,
136+ symbol : "" ,
137+ ariaHidden : false ,
138+ } ) ,
139+ level : [ 1 , 2 , 3 , 4 ] ,
140+ slugify : eleventyConfig . getFilter ( "slugify" )
141+ } ) ;
142+ } ) ;
143+
144+ // Pass through Tufte CSS and fonts
145+ eleventyConfig . addPassthroughCopy ( "src/css" ) ;
146+ eleventyConfig . addPassthroughCopy ( "src/et-book" ) ;
147+
94148 // run these configs in production only
95149 if ( process . env . ELEVENTY_ENV === 'production' ) {
96150 eleventyConfig . addTransform ( "htmlmin" , function ( content , outputPath ) {
0 commit comments