1- /*global module:false,require:false,console:false */
21module . exports = function ( grunt ) {
32
43 require ( 'matchdep' ) . filterDev ( 'grunt-*' ) . forEach ( grunt . loadNpmTasks ) ;
@@ -15,32 +14,11 @@ module.exports = function(grunt) {
1514 ' <%= pkg.license %> License */\n' ,
1615 config : {
1716 root : 'web/' , // from domain root, do not include the first slash, do include a trailing slash
18- // See also: yaml.vars.baseurl
1917 jsSrc : '<%= config.root %>js/' ,
2018 cssSrc : '<%= config.root %>css/' ,
2119 imgSrc : '<%= config.root %>img/' ,
2220 iconsSrc : '<%= config.imgSrc %>icons/' ,
23- distVersion : '<%= pkg.version %>' ,
24- distFolder : '<%= config.root %>dist/<%= pkg.version %>/' ,
25- distFeed : '<%- config.root %>_site/feed/atom.xml'
26- } ,
27- yaml : {
28- file : '<%= config.root %>_config.yml' ,
29- vars : {
30- name : 'Zach Leatherman' ,
31- description : 'A web development blog written by @zachleat.' ,
32- safe : false ,
33- future : true ,
34- baseurl : '/web' ,
35- markdown : 'kramdown' ,
36- highlighter : 'rouge' ,
37- // https://github.com/mojombo/jekyll/wiki/Permalinks
38- permalink : '/<%= config.root %>:title/' ,
39- relative_permalinks : false ,
40- distVersion : '<%= pkg.version %>' ,
41- distFolder : '/<%= config.distFolder %>' ,
42- avatarImgSrc : '/img/avatar-2017.png'
43- }
21+ distFolder : '<%= config.root %>dist/<%= pkg.version %>/'
4422 } ,
4523 // Task configuration.
4624 concat : {
@@ -98,31 +76,6 @@ module.exports = function(grunt) {
9876 dest : '<%= config.distFolder %>defer.min.js'
9977 }
10078 } ,
101- jshint : {
102- options : {
103- curly : true ,
104- eqeqeq : true ,
105- immed : true ,
106- latedef : true ,
107- newcap : true ,
108- noarg : true ,
109- sub : true ,
110- undef : true ,
111- unused : true ,
112- boss : true ,
113- eqnull : true ,
114- browser : true ,
115- // TODO make this only for Gruntfile.js
116- esversion : 6 ,
117- globals : { }
118- } ,
119- gruntfile : {
120- src : 'Gruntfile.js'
121- } ,
122- js : {
123- src : [ 'js/**/*.js' ]
124- }
125- } ,
12679 sass : {
12780 dist : {
12881 options : {
@@ -157,10 +110,12 @@ module.exports = function(grunt) {
157110 // For CSS inlining
158111 includes : {
159112 files : {
160- '<%= config.root %>_includes/dist/<%= pkg.version %>/initial.min.css' : [ '<%= config.distFolder %>initial.min.css' ] ,
161- '<%= config.root %>_includes/dist/<%= pkg.version %>/initial.css' : [ '<%= config.distFolder %>initial.css' ] ,
162- '<%= config.root %>_includes/dist/<%= pkg.version %>/initial.min.js' : [ '<%= config.distFolder %>initial.min.js' ] ,
163- '<%= config.root %>_includes/dist/<%= pkg.version %>/initial.js' : [ '<%= config.distFolder %>initial.js' ]
113+ // Copy this into data since we’re running in /web/ and don’t have access to the package.json (it’s up a dir)
114+ '<%= config.root %>_data/package.json' : [ 'package.json' ] ,
115+ '<%= config.root %>_includes/initial.min.css' : [ '<%= config.distFolder %>initial.min.css' ] ,
116+ '<%= config.root %>_includes/initial.css' : [ '<%= config.distFolder %>initial.css' ] ,
117+ '<%= config.root %>_includes/initial.min.js' : [ '<%= config.distFolder %>initial.min.js' ] ,
118+ '<%= config.root %>_includes/initial.js' : [ '<%= config.distFolder %>initial.js' ]
164119 }
165120 }
166121 } ,
@@ -236,24 +191,14 @@ module.exports = function(grunt) {
236191 }
237192 } ,
238193 shell : {
239- jekyll : {
240- // command: 'jekyll build --config _config.yml --trace --drafts',
241- command : 'jekyll build --config _config.yml --trace' ,
194+ eleventy : {
195+ command : 'eleventy --quiet' ,
242196 options : {
243197 execOptions : {
244198 cwd : '<%= config.root %>'
245199 }
246200 }
247201 } ,
248- // generate the pygments css file
249- pygments : {
250- command : 'pygmentize -S default -f html > pygments.css' ,
251- options : {
252- execOptions : {
253- cwd : '<%= config.cssSrc %>'
254- }
255- }
256- } ,
257202 // TODO https://github.com/shama/grunt-beep
258203 upload : {
259204 command : 'echo "Note: Requires an \'zachleat\' host in .ssh/config"; rsync --archive --verbose --stats --compress --rsh=ssh ./_site/ zachleat:/home/public/<%= config.root %>' ,
@@ -288,58 +233,19 @@ module.exports = function(grunt) {
288233 '<%= config.root %>_plugins/**/*' ,
289234 '<%= config.root %>_includes/**/*' ] ,
290235 tasks : [ 'content' ]
291- } ,
292- config : {
293- files : [ 'Gruntfile.js' ] ,
294- tasks : [ 'config' ]
295236 }
296237 }
297238 } ) ;
298239
299- grunt . registerTask ( 'yaml' , function ( ) {
300- var output = grunt . config ( 'yaml.file' ) ,
301- vars = grunt . config ( 'yaml.vars' ) ,
302- fs = require ( 'fs' ) ,
303- str = [ '# Autogenerated by `grunt config`' ] ;
304-
305- for ( var j in vars ) {
306- str . push ( j + ': ' + vars [ j ] ) ;
307- }
308-
309- var err = fs . writeFileSync ( output , str . join ( '\n' ) ) ;
310- if ( err ) {
311- console . log ( err ) ;
312- } else {
313- console . log ( output + ' write successful.' ) ;
314- }
315- } ) ;
316-
317- grunt . registerTask ( 'feedburner-size' , function ( ) {
318- var feed = grunt . config . get ( 'config.distFeed' ) ,
319- fs = require ( 'fs' ) ;
320-
321- var stats = fs . statSync ( feed ) ,
322- kbSize = Math . ceil ( stats . size / 1024 ) ,
323- isTooLarge = kbSize > 1024 ,
324- msg = 'Your atom.xml is ' + ( isTooLarge ? 'too large' : 'ok' ) + ' (' + kbSize + 'KB) for Feedburner (512KB max).' ;
325-
326- if ( isTooLarge ) {
327- grunt . fail . warn ( msg ) ;
328- } else {
329- grunt . log . writeln ( msg ) ;
330- }
331- } ) ;
332-
333240 grunt . task . loadTasks ( 'tasks' ) ;
334241
335242 // Default task.
336- grunt . registerTask ( 'assets' , [ 'copy:css-to-sass' , 'sass' , 'jshint' , ' concat', 'uglify' , 'cssmin' ] ) ;
243+ grunt . registerTask ( 'assets' , [ 'copy:css-to-sass' , 'sass' , 'concat' , 'uglify' , 'cssmin' ] ) ;
337244 grunt . registerTask ( 'images' , [ 'grunticon' ] ) ;
338- grunt . registerTask ( 'config' , [ 'yaml' ] ) ;
339- grunt . registerTask ( 'content' , [ 'copy:includes' , 'shell:jekyll' ] ) ;
340- grunt . registerTask ( 'default' , [ 'clean' , 'config' , 'assets' , 'images' , 'content' , 'feedburner-size' ] ) ;
245+ grunt . registerTask ( 'content' , [ 'copy:includes' , 'shell:eleventy' ] ) ;
246+ grunt . registerTask ( 'default' , [ 'clean' , 'assets' , 'images' , 'content' ] ) ;
341247
342248 // Upload to Production
343- grunt . registerTask ( 'stage' , [ 'clean' , 'config' , ' assets', 'images' , 'content' , 'feedburner-size ', 'htmlmin' , 'zopfli' ] ) ;
249+ grunt . registerTask ( 'stage' , [ 'clean' , 'assets' , 'images' , 'content' , 'htmlmin' , 'zopfli' ] ) ;
344250 grunt . registerTask ( 'deploy' , [ 'stage' , 'shell:upload' ] ) ;
345251} ;
0 commit comments