Skip to content

Commit c1b17c1

Browse files
committed
Add html-minifier
1 parent 663c527 commit c1b17c1

File tree

5 files changed

+87
-13
lines changed

5 files changed

+87
-13
lines changed

.eleventy.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const fs = require('fs');
22
const pluginRss = require('@11ty/eleventy-plugin-rss');
3+
const htmlmin = require('html-minifier');
34
const sassWatch = require('./_includes/sass-watch');
45
const filter = require('./_includes/filter');
56
const scAvatar = require('./_includes/shortcodes/avatar');
@@ -71,6 +72,23 @@ module.exports = (eleventyConfig) => {
7172
// PLUGIN: RSS feed
7273
eleventyConfig.addPlugin(pluginRss);
7374

75+
// TRANSFORM: minify HTML
76+
eleventyConfig.addTransform('htmlmin', (content, outputPath) => {
77+
if (typeof outputPath === 'string' && outputPath.endsWith('.html')) {
78+
const minified = htmlmin.minify(content, {
79+
useShortDoctype: true,
80+
removeComments: true,
81+
collapseWhitespace: true,
82+
minifyCSS: true,
83+
minifyJS: true,
84+
});
85+
86+
return minified;
87+
}
88+
89+
return content;
90+
});
91+
7492
// BROWSERSYNC: add ability to see 404.html in dev mode
7593
eleventyConfig.setBrowserSyncConfig({
7694
callbacks: {

_meetups/2016-01-19-meetup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: meetup
3-
title: Alex Sexton talks about client-side "security"
3+
title: Alex Sexton talks about client-side "security"
44
author: astacy
55
when: 2016-01-19T19:30:00-06:00
66
speakers:

index.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ <h1 class="is-sr-only">{{ title }}</h1>
1414
{%- meetupDetails meet.date, meet.data.venue, meet.data.after, 'Upcoming meetup details', meet.data.title, meet.url -%}
1515

1616
<meta id="meet-date" time="{{ meet.date }}">
17-
<script>
18-
(function () {
19-
const meetDate = document.getElementById('meet-date').getAttribute('time');
20-
21-
if (new Date(meetDate) < new Date()) {
22-
// We may want to post an alternate message, but for now just delete the upcoming meetup.
23-
document.querySelector('.meetup-details').remove();
24-
}
25-
}());
26-
</script>
2717
</section>
2818

2919
<section class="section">

package-lock.json

Lines changed: 67 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@11ty/eleventy-plugin-rss": "^1.0.7",
2828
"acorn": ">=5.7.4",
2929
"bulma": "^0.8.2",
30+
"html-minifier": "^4.0.0",
3031
"lodash": "^4.17.19",
3132
"node-sass": "^4.14.0",
3233
"purgecss": "^2.3.0"

0 commit comments

Comments
 (0)