1
1
const htmlmin = require ( "html-minifier" ) ;
2
- const markdownIt = require ( ' markdown-it' ) ;
2
+ const markdownIt = require ( " markdown-it" ) ;
3
3
const pluginRss = require ( "@11ty/eleventy-plugin-rss" ) ;
4
4
5
- const isProd = process . env . ELEVENTY_ENV === ' prod'
6
- const outDir = ' public'
5
+ const isProd = process . env . ELEVENTY_ENV === " prod" ;
6
+ const outDir = " public" ;
7
7
8
8
module . exports = function ( eleventyConfig ) {
9
- // PLUGINS
10
- eleventyConfig . addPlugin ( pluginRss ) ;
11
-
12
- // shortcode to render markdown from string => {{ STRING | markdown | safe }}
13
- eleventyConfig . addFilter ( 'markdown' , function ( value ) {
14
- let markdown = require ( 'markdown-it' ) ( {
15
- html : true
16
- } ) ;
17
- return markdown . render ( value ) ;
18
- } ) ;
19
-
20
- // rebuild on CSS changes
21
- eleventyConfig . addWatchTarget ( './src/_includes/css/' ) ;
22
-
23
- // Markdown
24
- eleventyConfig . setLibrary (
25
- 'md' ,
26
- markdownIt ( {
27
- html : true ,
28
- breaks : true ,
29
- linkify : true ,
30
- typographer : true
31
- } )
32
- )
33
-
34
- //create collections
35
- eleventyConfig . addCollection ( 'sections' , async ( collection ) => {
36
- return collection . getFilteredByGlob ( './src/sections/*.md' ) ;
37
- } ) ;
38
-
39
- // STATIC FILES
40
- eleventyConfig . addPassthroughCopy ( { './src/static/' : '/' } ) ;
41
-
42
- // TRANSFORM -- Minify HTML Output
43
- eleventyConfig . addTransform ( "htmlmin" , function ( content , outputPath ) {
44
- if ( outputPath && outputPath . endsWith ( ".html" ) ) {
45
- let minified = htmlmin . minify ( content , {
46
- useShortDoctype : true ,
47
- removeComments : true ,
48
- collapseWhitespace : true
49
- } ) ;
50
- return minified ;
51
- }
52
- return content ;
53
- } ) ;
54
-
55
- return {
56
- pathPrefix : isProd ? "inpycon2025" : "" ,
57
- dir : {
58
- input : 'src' ,
59
- output : outDir ,
60
- data : './_data' ,
61
- includes : './_includes' ,
62
- layouts : './_layouts'
63
- } ,
64
- templateFormats : [
65
- 'md' ,
66
- 'njk' ,
67
- '11ty.js'
68
- ] ,
69
- htmlTemplateEngine : 'njk'
70
- } ;
71
- } ;
9
+ // PLUGINS
10
+ eleventyConfig . addPlugin ( pluginRss ) ;
11
+
12
+ // shortcode to render markdown from string => {{ STRING | markdown | safe }}
13
+ eleventyConfig . addFilter ( "markdown" , function ( value ) {
14
+ let markdown = require ( "markdown-it" ) ( {
15
+ html : true ,
16
+ } ) ;
17
+ return markdown . render ( value ) ;
18
+ } ) ;
19
+
20
+ eleventyConfig . addFilter ( "dateInfo" , function ( dateStr ) {
21
+ // Get day of month
22
+ const dayOfMonth = parseInt ( dateStr . split ( "-" ) [ 2 ] ) ;
23
+
24
+ // Default result
25
+ let result = {
26
+ dayName : "NA" ,
27
+ monthDay : "NA" ,
28
+ label : "NA" ,
29
+ } ;
30
+
31
+ // Mapping logic
32
+ switch ( dayOfMonth ) {
33
+ case 12 :
34
+ result = {
35
+ dayName : "Friday" ,
36
+ monthDay : "September 12th" ,
37
+ label : "Workshop Day" ,
38
+ } ;
39
+ break ;
40
+ case 13 :
41
+ result = {
42
+ dayName : "Saturday" ,
43
+ monthDay : "September 13th" ,
44
+ label : "Conference Day 1" ,
45
+ } ;
46
+ break ;
47
+ case 14 :
48
+ result = {
49
+ dayName : "Sunday" ,
50
+ monthDay : "September 14th" ,
51
+ label : "Conference Day 2" ,
52
+ } ;
53
+ break ;
54
+ case 15 :
55
+ result = {
56
+ dayName : "Monday" ,
57
+ monthDay : "September 15th" ,
58
+ label : "DevSprint" ,
59
+ } ;
60
+ break ;
61
+ }
62
+
63
+ return result ;
64
+ } ) ;
65
+
66
+ eleventyConfig . addFilter ( "getEndTime" , function ( startTime , duration ) {
67
+ const [ sh , sm ] = startTime . split ( ":" ) . map ( Number ) ;
68
+ const [ dh , dm ] = duration . split ( ":" ) . map ( Number ) ;
69
+
70
+ // Total minutes
71
+ let totalMinutes = sh * 60 + sm + dh * 60 + dm ;
72
+
73
+ // Calculate end hour and minutes
74
+ let endHour = Math . floor ( totalMinutes / 60 ) ;
75
+ let endMinute = totalMinutes % 60 ;
76
+
77
+ // Wrap around 24 hours (optional, if needed)
78
+ if ( endHour >= 24 ) endHour = endHour % 24 ;
79
+
80
+ // Pad with zero if needed
81
+ const endHourStr = endHour . toString ( ) . padStart ( 2 , "0" ) ;
82
+ const endMinuteStr = endMinute . toString ( ) . padStart ( 2 , "0" ) ;
83
+
84
+ return `${ endHourStr } :${ endMinuteStr } ` ;
85
+ } ) ;
86
+
87
+ // rebuild on CSS changes
88
+ eleventyConfig . addWatchTarget ( "./src/_includes/css/" ) ;
89
+
90
+ // Markdown
91
+ eleventyConfig . setLibrary (
92
+ "md" ,
93
+ markdownIt ( {
94
+ html : true ,
95
+ breaks : true ,
96
+ linkify : true ,
97
+ typographer : true ,
98
+ } )
99
+ ) ;
100
+
101
+ //create collections
102
+ eleventyConfig . addCollection ( "sections" , async ( collection ) => {
103
+ return collection . getFilteredByGlob ( "./src/sections/*.md" ) ;
104
+ } ) ;
105
+
106
+ // STATIC FILES
107
+ eleventyConfig . addPassthroughCopy ( { "./src/static/" : "/" } ) ;
108
+
109
+ // TRANSFORM -- Minify HTML Output
110
+ eleventyConfig . addTransform ( "htmlmin" , function ( content , outputPath ) {
111
+ if ( outputPath && outputPath . endsWith ( ".html" ) ) {
112
+ let minified = htmlmin . minify ( content , {
113
+ useShortDoctype : true ,
114
+ removeComments : true ,
115
+ collapseWhitespace : true ,
116
+ } ) ;
117
+ return minified ;
118
+ }
119
+ return content ;
120
+ } ) ;
121
+
122
+ return {
123
+ pathPrefix : isProd ? "inpycon2025" : "" ,
124
+ dir : {
125
+ input : "src" ,
126
+ output : outDir ,
127
+ data : "./_data" ,
128
+ includes : "./_includes" ,
129
+ layouts : "./_layouts" ,
130
+ } ,
131
+ templateFormats : [ "md" , "njk" , "11ty.js" ] ,
132
+ htmlTemplateEngine : "njk" ,
133
+ } ;
134
+ } ;
0 commit comments