@@ -16,84 +16,84 @@ const parseTransform = require('./src/transforms/parse-transform.js');
1616const site = require ( './src/_data/site.json' ) ;
1717
1818module . exports = function ( config ) {
19- // Filters
20- config . addFilter ( 'dateFilter' , dateFilter ) ;
21- config . addFilter ( 'markdownFilter' , markdownFilter ) ;
22- config . addFilter ( 'w3DateFilter' , w3DateFilter ) ;
23-
24- // Layout aliases
25- config . addLayoutAlias ( 'home' , 'layouts/home.njk' ) ;
26-
27- // Transforms
28- config . addTransform ( 'htmlmin' , htmlMinTransform ) ;
29- config . addTransform ( 'parse' , parseTransform ) ;
30-
31- // Passthrough copy
32- config . addPassthroughCopy ( 'src/images' ) ;
33- config . addPassthroughCopy ( 'src/js' ) ;
34- config . addPassthroughCopy ( 'src/admin/config.yml' ) ;
35- config . addPassthroughCopy ( 'src/admin/previews.js' ) ;
36- config . addPassthroughCopy ( {
37- '../../node_modules/nunjucks/browser/nunjucks-slim.js' :
38- 'node_modules/nunjucks/browser/nunjucks-slim.js' ,
39- } ) ;
40-
41- const now = new Date ( ) ;
42-
43- // Custom collections
44- const livePosts = ( post ) => post . date <= now && ! post . data . draft ;
45- config . addCollection ( 'posts' , ( collection ) => {
46- return [
47- ...collection . getFilteredByGlob ( './src/posts/*.md' ) . filter ( livePosts ) ,
48- ] . reverse ( ) ;
49- } ) ;
50-
51- config . addCollection ( 'demos' , ( collection ) => {
52- return [ ...collection . getFilteredByGlob ( './src/demos/*.md' ) ] . reverse ( ) ;
53- } ) ;
54-
55- config . addCollection ( 'postFeed' , ( collection ) => {
56- return [ ...collection . getFilteredByGlob ( './src/posts/*.md' ) . filter ( livePosts ) ]
57- . reverse ( )
58- . slice ( 0 , site . maxPostsPerPage ) ;
59- } ) ;
60-
61- config . addCollection ( 'docs' , ( collection ) => {
62- return [ ...collection . getFilteredByGlob ( './src/docs/*.md' ) ] . reverse ( ) ;
63- } ) ;
64-
65- config . addCollection ( 'docsOrdered' , ( collection ) => {
66- const docs = collection . getFilteredByGlob ( 'src/docs/*.md' ) . sort ( ( a , b ) => {
67- return Number ( a . data . order ) - Number ( b . data . order ) ;
68- } ) ;
69- return docs ;
70- } ) ;
71-
72- // Plugins
73- config . addPlugin ( rssPlugin ) ;
74- config . addPlugin ( syntaxHighlight ) ;
75- config . addPlugin ( eleventyNavigationPlugin ) ;
76-
77- // 404
78- config . setBrowserSyncConfig ( {
79- callbacks : {
80- ready : function ( err , browserSync ) {
81- const content_404 = fs . readFileSync ( 'dist/404.html' ) ;
82-
83- browserSync . addMiddleware ( '*' , ( req , res ) => {
84- // Provides the 404 content without redirect.
85- res . write ( content_404 ) ;
86- res . end ( ) ;
87- } ) ;
88- } ,
89- } ,
90- } ) ;
91-
92- return {
93- dir : {
94- input : 'src' ,
95- output : 'dist' ,
96- } ,
97- passthroughFileCopy : true ,
98- } ;
19+ // Filters
20+ config . addFilter ( 'dateFilter' , dateFilter ) ;
21+ config . addFilter ( 'markdownFilter' , markdownFilter ) ;
22+ config . addFilter ( 'w3DateFilter' , w3DateFilter ) ;
23+
24+ // Layout aliases
25+ config . addLayoutAlias ( 'home' , 'layouts/home.njk' ) ;
26+
27+ // Transforms
28+ config . addTransform ( 'htmlmin' , htmlMinTransform ) ;
29+ config . addTransform ( 'parse' , parseTransform ) ;
30+
31+ // Passthrough copy
32+ config . addPassthroughCopy ( 'src/images' ) ;
33+ config . addPassthroughCopy ( 'src/js' ) ;
34+ config . addPassthroughCopy ( 'src/admin/config.yml' ) ;
35+ config . addPassthroughCopy ( 'src/admin/previews.js' ) ;
36+ config . addPassthroughCopy ( {
37+ '../../node_modules/nunjucks/browser/nunjucks-slim.js' :
38+ 'node_modules/nunjucks/browser/nunjucks-slim.js' ,
39+ } ) ;
40+
41+ const now = new Date ( ) ;
42+
43+ // Custom collections
44+ const livePosts = ( post ) => post . date <= now && ! post . data . draft ;
45+ config . addCollection ( 'posts' , ( collection ) => {
46+ return [
47+ ...collection . getFilteredByGlob ( './src/posts/*.md' ) . filter ( livePosts ) ,
48+ ] . reverse ( ) ;
49+ } ) ;
50+
51+ config . addCollection ( 'demos' , ( collection ) => {
52+ return [ ...collection . getFilteredByGlob ( './src/demos/*.md' ) ] . reverse ( ) ;
53+ } ) ;
54+
55+ config . addCollection ( 'postFeed' , ( collection ) => {
56+ return [ ...collection . getFilteredByGlob ( './src/posts/*.md' ) . filter ( livePosts ) ]
57+ . reverse ( )
58+ . slice ( 0 , site . maxPostsPerPage ) ;
59+ } ) ;
60+
61+ config . addCollection ( 'docs' , ( collection ) => {
62+ return [ ...collection . getFilteredByGlob ( './src/docs/*.md' ) ] . reverse ( ) ;
63+ } ) ;
64+
65+ config . addCollection ( 'docsOrdered' , ( collection ) => {
66+ const docs = collection . getFilteredByGlob ( 'src/docs/*.md' ) . sort ( ( a , b ) => {
67+ return Number ( a . data . order ) - Number ( b . data . order ) ;
68+ } ) ;
69+ return docs ;
70+ } ) ;
71+
72+ // Plugins
73+ config . addPlugin ( rssPlugin ) ;
74+ config . addPlugin ( syntaxHighlight ) ;
75+ config . addPlugin ( eleventyNavigationPlugin ) ;
76+
77+ // 404
78+ config . setBrowserSyncConfig ( {
79+ callbacks : {
80+ ready : function ( err , browserSync ) {
81+ const content_404 = fs . readFileSync ( 'dist/404.html' ) ;
82+
83+ browserSync . addMiddleware ( '*' , ( req , res ) => {
84+ // Provides the 404 content without redirect.
85+ res . write ( content_404 ) ;
86+ res . end ( ) ;
87+ } ) ;
88+ } ,
89+ } ,
90+ } ) ;
91+
92+ return {
93+ dir : {
94+ input : 'src' ,
95+ output : 'dist' ,
96+ } ,
97+ passthroughFileCopy : true ,
98+ } ;
9999} ;
0 commit comments