Skip to content

Commit 0e10b08

Browse files
committed
Initial working copy of my web site running on eleventy! 😮
1 parent 5e17319 commit 0e10b08

File tree

62 files changed

+1806
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1806
-318
lines changed

‎Gruntfile.js‎

Lines changed: 13 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/*global module:false,require:false,console:false */
21
module.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
};

‎package.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zachleat.com",
3-
"version": "0.5.9",
3+
"version": "1.0.0",
44
"description": "The website of @zachleat",
55
"dependencies": {
66
"fg-loadcss": "^1.3.1",
@@ -11,6 +11,9 @@
1111
},
1212
"private": true,
1313
"devDependencies": {
14+
"@11ty/eleventy": "^0.2.13",
15+
"@11ty/eleventy-plugin-rss": "^1.0.1",
16+
"@11ty/eleventy-plugin-syntaxhighlight": "^1.0.0",
1417
"cheerio": "^1.0.0-rc.2",
1518
"gray-matter": "^3.0.2",
1619
"grunt": "~1.0.1",
@@ -21,7 +24,6 @@
2124
"grunt-contrib-copy": "~1.0.0",
2225
"grunt-contrib-cssmin": "~2.2.0",
2326
"grunt-contrib-htmlmin": "~2.4.0",
24-
"grunt-contrib-jshint": "~1.1.0",
2527
"grunt-contrib-sass": "~1.0.0",
2628
"grunt-contrib-uglify": "~3.0.1",
2729
"grunt-contrib-watch": "~1.0.0",

‎web/.eleventy.js‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const pluginRss = require("@11ty/eleventy-plugin-rss");
2+
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
3+
4+
module.exports = function(eleventyConfig) {
5+
eleventyConfig.addPlugin(pluginRss);
6+
eleventyConfig.addPlugin(pluginSyntaxHighlight);
7+
8+
eleventyConfig.addLayoutAlias('default', 'layouts/default.liquid');
9+
eleventyConfig.addLayoutAlias('page', 'layouts/page.liquid');
10+
eleventyConfig.addLayoutAlias('post', 'layouts/post.liquid');
11+
12+
eleventyConfig.addLiquidFilter("reading_time", function(content) {
13+
return "a few minutes";
14+
});
15+
16+
function postsMarkdown(item) {
17+
// Only return content that was originally a markdown file
18+
let extension = item.inputPath.split('.').pop();
19+
return item.inputPath.indexOf("./_posts/") === 0 && extension === "md";
20+
}
21+
22+
eleventyConfig.addCollection("posts", function(collection) {
23+
return collection.getAllSorted().reverse().filter(postsMarkdown);
24+
});
25+
26+
// font-loading category mapped to collection
27+
eleventyConfig.addCollection("font-loading", function(collection) {
28+
return collection.getAllSorted().filter(function(item) {
29+
return "categories" in item.data && item.data.categories && item.data.categories.indexOf("font-loading") > -1;
30+
}).reverse();
31+
});
32+
33+
// projects
34+
eleventyConfig.addCollection("projects", function(collection) {
35+
return collection.getFilteredByTag("project").reverse();
36+
});
37+
38+
// presentations category mapped to collection
39+
eleventyConfig.addCollection("presentations", function(collection) {
40+
return collection.getAllSorted().filter(function(item) {
41+
return "categories" in item.data && item.data.categories && item.data.categories.indexOf("presentations") > -1;
42+
}).reverse();
43+
});
44+
45+
eleventyConfig.addCollection("popularPostsRanked", function(collection) {
46+
return collection.getFilteredByTag("popular-posts").sort(function(a, b) {
47+
return b.data.postRank - a.data.postRank;
48+
}).reverse();
49+
});
50+
51+
eleventyConfig.addCollection("popularPostsTotalRanked", function(collection) {
52+
return collection.getFilteredByTag("popular-posts-total").sort(function(a, b) {
53+
return b.data.postRankTotalViews - a.data.postRankTotalViews;
54+
}).reverse();
55+
});
56+
57+
eleventyConfig.addCollection("feedPosts", function(collection) {
58+
return collection.getAllSorted().reverse().filter(postsMarkdown).filter(function(item) {
59+
return !item.data.tags ||
60+
item.data.tags.indexOf("deprecated") === -1 &&
61+
item.data.tags.indexOf("feedtrim") === -1 &&
62+
item.data.tags.indexOf("upcoming") === -1 &&
63+
item.data.tags.indexOf("pending") === -1;
64+
});
65+
});
66+
67+
return {
68+
"templateFormats": [
69+
"liquid",
70+
"md",
71+
"njk",
72+
"html",
73+
"woff2",
74+
"woff",
75+
"css",
76+
"js",
77+
"jpg",
78+
"png",
79+
"webp",
80+
"mp4"
81+
],
82+
"pathPrefix": "/web/",
83+
"passthroughFileCopy": true,
84+
"htmlTemplateEngine": "liquid",
85+
"markdownTemplateEngine": "liquid"
86+
};
87+
};

‎web/.eleventyignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_drafts/

‎web/_data/package.json‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "zachleat.com",
3+
"version": "1.0.0",
4+
"description": "The website of @zachleat",
5+
"dependencies": {
6+
"fg-loadcss": "^1.3.1",
7+
"fg-loadjs": "^1.0.0",
8+
"fontfaceobserver": "^2.0.13",
9+
"fontfaceonload": "^1.0.2",
10+
"infinity-burger": "^2.0.3"
11+
},
12+
"private": true,
13+
"devDependencies": {
14+
"@11ty/eleventy": "^0.2.13",
15+
"@11ty/eleventy-plugin-rss": "^1.0.1",
16+
"@11ty/eleventy-plugin-syntaxhighlight": "^1.0.0",
17+
"cheerio": "^1.0.0-rc.2",
18+
"gray-matter": "^3.0.2",
19+
"grunt": "~1.0.1",
20+
"grunt-cli": "~1.2.0",
21+
"grunt-contrib-clean": "^1.1.0",
22+
"grunt-contrib-compress": "~1.4.3",
23+
"grunt-contrib-concat": "~1.0.1",
24+
"grunt-contrib-copy": "~1.0.0",
25+
"grunt-contrib-cssmin": "~2.2.0",
26+
"grunt-contrib-htmlmin": "~2.4.0",
27+
"grunt-contrib-sass": "~1.0.0",
28+
"grunt-contrib-uglify": "~3.0.1",
29+
"grunt-contrib-watch": "~1.0.0",
30+
"grunt-grunticon": "^2.3.2",
31+
"grunt-shell": "~2.1.0",
32+
"grunt-zopfli": "^0.3.3",
33+
"install": "~0.10.1",
34+
"lodash.remove": "^4.7.0",
35+
"lodash.uniq": "^4.5.0",
36+
"matchdep": "~1.0.1",
37+
"npm": "~5.0.4",
38+
"time-grunt": "^1.4.0"
39+
},
40+
"scripts": {
41+
"bestof": "grunt bestof && grunt"
42+
},
43+
"repository": {
44+
"type": "git",
45+
"url": "git://github.com/zachleat/zachleat.com.git"
46+
},
47+
"author": "Zach Leatherman",
48+
"license": "MIT"
49+
}

‎web/_data/site.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Zach Leatherman",
3+
"description": "A web development blog written by @zachleat.",
4+
"avatarImgSrc": "/img/avatar-2017.png"
5+
}

0 commit comments

Comments
 (0)