1
- const { DateTime } = require ( "luxon" ) ;
1
+ const { DateTime } = require ( "luxon" )
2
2
const readingTime = require ( 'eleventy-plugin-reading-time' )
3
3
const embedEverything = require ( "eleventy-plugin-embed-everything" )
4
- const pluginRss = require ( "@11ty/eleventy-plugin-rss" ) ;
5
- const pluginSyntaxHighlight = require ( "@11ty/eleventy-plugin-syntaxhighlight" ) ;
6
- const markdownIt = require ( "markdown-it" ) ;
7
- const markdownItAnchor = require ( "markdown-it-anchor" ) ;
8
- const markdownItFootnote = require ( "markdown-it-footnote" ) ;
4
+ const pluginRss = require ( "@11ty/eleventy-plugin-rss" )
5
+ const pluginSyntaxHighlight = require ( "@11ty/eleventy-plugin-syntaxhighlight" )
6
+ const markdownIt = require ( "markdown-it" )
7
+ const markdownItAnchor = require ( "markdown-it-anchor" )
8
+ const markdownItFootnote = require ( "markdown-it-footnote" )
9
9
const markdownItContainer = require ( "markdown-it-container" )
10
10
const markdownItResponsive = require ( '@gerhobbelt/markdown-it-responsive' )
11
11
12
12
const transforms = require ( './utils/transforms.js' )
13
13
const filters = require ( './utils/filters.js' )
14
14
15
15
const now = new Date ( )
16
- const envLong = process . env . NODE_ENV
17
16
18
17
module . exports = ( config ) => {
19
- config . addPlugin ( pluginRss ) ;
20
- config . addPlugin ( pluginSyntaxHighlight ) ;
18
+ config . addPlugin ( pluginRss )
19
+ config . addPlugin ( pluginSyntaxHighlight )
21
20
config . addPlugin ( readingTime )
22
21
config . addPlugin ( embedEverything )
23
22
24
23
// Transforms
25
24
Object . keys ( transforms ) . forEach ( ( transformName ) => {
26
- config . addTransform ( transformName , transforms [ transformName ] ) ;
27
- } ) ;
25
+ config . addTransform ( transformName , transforms [ transformName ] )
26
+ } )
28
27
29
28
// Filters
30
29
Object . keys ( filters ) . forEach ( ( filterName ) => {
31
- config . addFilter ( filterName , filters [ filterName ] ) ;
32
- } ) ;
30
+ config . addFilter ( filterName , filters [ filterName ] )
31
+ } )
33
32
34
33
const isDraftOrIndex = ( post ) => {
35
34
if ( post . data . draft ) return false
@@ -51,19 +50,15 @@ module.exports = (config) => {
51
50
return true
52
51
}
53
52
54
- config . addPassthroughCopy ( "assets/favicon" ) ;
55
- config . addPassthroughCopy ( { 'assets/chrisspiegl.asc' : 'chrisspiegl.asc' } ) ;
53
+ config . addPassthroughCopy ( "assets/favicon" )
54
+ config . addPassthroughCopy ( { 'assets/chrisspiegl.asc' : 'chrisspiegl.asc' } )
56
55
57
56
config . addCollection ( 'posts' , collection => {
58
57
return collection . getFilteredByGlob ( './post/**/*.md' ) . filter ( _ => livePosts ( _ ) ) . reverse ( )
59
58
} )
60
59
61
60
config . addCollection ( 'drafts' , collection => {
62
- return collection . getFilteredByGlob ( './post/**/*.md' ) . filter ( _ => ! livePosts ( _ ) ) . reverse ( ) ;
63
- } )
64
-
65
- config . addCollection ( 'podcasts' , collection => {
66
- return collection . getFilteredByGlob ( './podcast/**/*.md' ) . filter ( _ => livePosts ( _ ) ) . reverse ( )
61
+ return collection . getFilteredByGlob ( './post/**/*.md' ) . filter ( _ => ! livePosts ( _ ) ) . reverse ( )
67
62
} )
68
63
69
64
config . addCollection ( 'books' , ( collection ) => {
@@ -91,28 +86,31 @@ module.exports = (config) => {
91
86
92
87
for ( const tag of tags )
93
88
tag . startsWith ( '_' ) || uniqueTags . add ( tag )
94
- } ) ;
89
+ } )
95
90
96
- return [ ...uniqueTags ] ;
91
+ return [ ...uniqueTags ]
97
92
} )
98
93
94
+ // The ever-popular markdown filter.
95
+
99
96
let md = markdownIt ( {
100
97
html : true ,
101
98
breaks : true ,
102
99
linkify : true ,
103
100
typographer : true ,
104
101
} )
105
102
106
- // The ever-popular markdown filter.
107
103
config . addFilter ( "markdown" , ( content ) => md . render ( content ) )
108
104
109
105
md . use ( markdownItAnchor , {
110
106
permalink : true ,
111
107
permalinkClass : 'direct-link' ,
112
108
permalinkSymbol : '' ,
113
109
} )
114
- . use ( markdownItFootnote )
115
- . use ( markdownItContainer , 'image-hero' , { marker : '!' } )
110
+
111
+ md . use ( markdownItFootnote )
112
+
113
+ md . use ( markdownItContainer , 'image-hero' , { marker : '!' } )
116
114
. use ( markdownItContainer , 'signature' , { marker : '!' } )
117
115
. use ( markdownItContainer , 'image-sbs' , { marker : '!' } )
118
116
. use ( markdownItContainer , 'text-center' , { marker : '!' } )
@@ -126,7 +124,7 @@ module.exports = (config) => {
126
124
return true
127
125
} ,
128
126
render : function ( tokens , idx ) {
129
- var m = tokens [ idx ] . info . trim ( ) // .match(/^well\s+(.*)$/);
127
+ var m = tokens [ idx ] . info . trim ( ) // .match(/^well\s+(.*)$/)
130
128
if ( tokens [ idx ] . nesting === 1 ) {
131
129
// opening tag
132
130
let summary = m === '' ? '' : '<summary>' + md . renderInline ( m ) + '</summary>\n'
@@ -140,81 +138,76 @@ module.exports = (config) => {
140
138
141
139
// Responsive Images inside Markdown
142
140
143
- const imageResizer = ( width , height , origin ) => {
144
- baseUrl = ! origin . startsWith ( 'https://' ) && ! origin . startsWith ( 'http://' ) ? `https://chrisspiegl.com${ origin } ` : origin
145
- if ( process . env . ELEVENTY_ENV == 'production' ) return `https://wrender.spiegl.co/resize/${ width } /${ height } /${ baseUrl } `
146
- else return `${ origin } `
147
- }
148
- md . use ( markdownItResponsive , {
149
- responsive : {
150
- srcset : {
151
- "*.jpg" : [
152
- {
153
- width : 320 ,
154
- rename : { suffix : "-320w" } ,
155
- } ,
156
- {
157
- width : 640 ,
158
- rename : { suffix : "-640w" } ,
159
- } ,
160
- {
161
- width : 1280 ,
162
- rename : { suffix : "-1280w" } ,
163
- } ,
164
- {
165
- width : 1920 ,
166
- rename : { suffix : "-1920w" } ,
167
- } ,
168
- // {
169
- // width: 3840,
170
- // rename: { suffix: "-3840w" },
171
- // },
172
- ] ,
173
- "*.png" : [
174
- {
175
- width : 320 ,
176
- rename : { suffix : "-320w" } ,
177
- } ,
178
- {
179
- width : 640 ,
180
- rename : { suffix : "-640w" } ,
181
- } ,
182
- {
183
- width : 1280 ,
184
- rename : { suffix : "-1280w" } ,
185
- } ,
186
- {
187
- width : 1920 ,
188
- rename : { suffix : "-1920w" } ,
189
- } ,
190
- // {
191
- // width: 3840,
192
- // rename: { suffix: "-3840w" },
193
- // },
194
- ] ,
195
- } ,
196
-
197
- sizes : {
198
- // "*": "(max-width: 320px), (max-width: 640px), (max-width: 1280px), 1920px",
199
- } ,
141
+ md . use ( markdownItResponsive , {
142
+ responsive : {
143
+ srcset : {
144
+ "*.jpg" : [
145
+ {
146
+ width : 320 ,
147
+ rename : { suffix : "-320w" } ,
148
+ } ,
149
+ {
150
+ width : 640 ,
151
+ rename : { suffix : "-640w" } ,
152
+ } ,
153
+ {
154
+ width : 1280 ,
155
+ rename : { suffix : "-1280w" } ,
156
+ } ,
157
+ {
158
+ width : 1920 ,
159
+ rename : { suffix : "-1920w" } ,
160
+ } ,
161
+ // {
162
+ // width: 3840,
163
+ // rename: { suffix: "-3840w" },
164
+ // },
165
+ ] ,
166
+ "*.png" : [
167
+ {
168
+ width : 320 ,
169
+ rename : { suffix : "-320w" } ,
170
+ } ,
171
+ {
172
+ width : 640 ,
173
+ rename : { suffix : "-640w" } ,
174
+ } ,
175
+ {
176
+ width : 1280 ,
177
+ rename : { suffix : "-1280w" } ,
178
+ } ,
179
+ {
180
+ width : 1920 ,
181
+ rename : { suffix : "-1920w" } ,
182
+ } ,
183
+ // {
184
+ // width: 3840,
185
+ // rename: { suffix: "-3840w" },
186
+ // },
187
+ ] ,
188
+ } ,
189
+
190
+ sizes : {
191
+ // "*": "(max-width: 320px), (max-width: 640px), (max-width: 1280px), 1920px",
200
192
} ,
201
- } ) ;
193
+ } ,
194
+ } )
202
195
203
196
md . renderer . rules . footnote_caption = ( tokens , idx ) => {
204
- let n = Number ( tokens [ idx ] . meta . id + 1 ) . toString ( ) ;
197
+ let n = Number ( tokens [ idx ] . meta . id + 1 ) . toString ( )
205
198
206
199
if ( tokens [ idx ] . meta . subId > 0 ) {
207
- n += ":" + tokens [ idx ] . meta . subId ;
200
+ n += ":" + tokens [ idx ] . meta . subId
208
201
}
209
202
210
- return n ;
211
- } ;
203
+ return n
204
+ }
212
205
213
- config . setLibrary ( "md" , md ) ;
206
+ config . setLibrary ( "md" , md )
214
207
215
208
return {
216
209
dir : {
217
- output : `_site_ ${ envLong } ` ,
210
+ output : `_site ` ,
218
211
} ,
219
212
// dir: {
220
213
// output: "dist",
@@ -230,6 +223,6 @@ module.exports = (config) => {
230
223
// dataTemplateEngine: "njk",
231
224
// htmlTemplateEngine: "njk",
232
225
markdownTemplateEngine : "njk" ,
233
- passthroughFileCopy : true
226
+ passthroughFileCopy : true ,
234
227
}
235
228
}
0 commit comments