-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheleventy.config.js
74 lines (56 loc) · 1.94 KB
/
eleventy.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const fs = require("fs");
const path = require("path");
const htmlmin = require("html-minifier");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
// module import collections
const { getAllPosts } = require('./config/collections.js');
module.exports = function (eleventyConfig) {
if (process.env.ELEVENTY_PRODUCTION) {
eleventyConfig.addTransform("htmlmin", htmlminTransform);
}
console.log(process.env);
eleventyConfig.setServerOptions({
showAllHosts: true,
port: 8080
});
// Passthrough static files
eleventyConfig.addPassthroughCopy({ "./src/static": "." });
eleventyConfig.addPassthroughCopy({ "./src/admin/config.yml": "./admin/config.yml"});
eleventyConfig.addPassthroughCopy('./src/images/**/*.gif');
// Passthrough fonts (also needed at ./fonts for font.conf)
eleventyConfig.addPassthroughCopy({ "./fonts": "/fonts" });
// Watch targets
eleventyConfig.addWatchTarget("./src/styles/");
// RSS feeds
eleventyConfig.addPlugin(pluginRss);
// Filters
eleventyConfig.addPlugin(require('./config/filters.js'));
// Work with subdirectories as root
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
// Collections
eleventyConfig.addCollection('blogposts', getAllPosts);
// Images
eleventyConfig.addPlugin(require('./config/images.js'));
var pathPrefix = "";
if (process.env.GITHUB_REPOSITORY) {
pathPrefix = process.env.GITHUB_REPOSITORY.split('/')[1];
}
return {
dir: {
input: "src",
},
pathPrefix
}
};
function htmlminTransform(content, outputPath) {
if (outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
return minified;
}
return content;
}