1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
reyasume/.eleventy.js

64 lines
1.4 KiB

Set up for Eleventy and add resources. Squashed commit of the following: commit 58781e4e2c883b7a26d371250ed1f3aa88dcc7bf Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 17:36:30 2020 +0900 Set up the basic eleventy templates. commit a5adff6749345e2a08895b6d6efe976fd6712d60 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 16:55:50 2020 +0900 Install markdown-it and set up .eleventy.js commit fc6f413e80fc77048af1d9f391d5ad1623b171c2 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 16:23:35 2020 +0900 Add .nvmrc and netlify.toml for deployment commit fe7ee3d07ea9606e17bf66503aa8758e5669e732 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 16:14:24 2020 +0900 Add .eleventyignore which skips README.md. commit 4614029ef4529537cc13a64dd8cb854fdc57a6a6 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 16:07:03 2020 +0900 Add npx and cross-env, scripts, more links. commit 21e7127a5f7bd0245aa46db333c5d1ee6b988476 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 15:55:32 2020 +0900 Add Netlify status badge to README.md. commit 5a4dc75f8ec8fdbd555aa00c34cf01451eb76517 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 15:50:50 2020 +0900 Install Eleventy. commit 1680633c111ffd8e8d3348f81995d2e141eae2b4 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 15:46:52 2020 +0900 Add initial tiny package.json. commit d33a877725172cbd7f5ff0f7d6bfc69293bc7079 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 15:42:21 2020 +0900 Add a basic node-stuff .gitignore. commit c38c934f7f2a2a20740d7652024ec6472462772e Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 15:38:39 2020 +0900 Add something like a real README.md. commit 586a2d680aa68983b66e1d5b7eb372f0df31a690 Author: Mari <mstaib.git@reya.zone> Date: Sun Jan 12 15:25:02 2020 +0900 Add commissioned art and favicon package
5 years ago
const HTMLMinifier = require("html-minifier");
const CleanCSS = require("clean-css");
const UglifyES = require("uglify-es");
const MarkdownIt = require("markdown-it");
const markdownIt = MarkdownIt({
html: true,
breaks: true,
linkify: true
});
module.exports = function(eleventyConfig) {
eleventyConfig.setLibrary("md", markdownIt);
eleventyConfig.addPassthroughCopy({
"static/favicon": ".",
"static/img": "img"
});
eleventyConfig.addTransform("minifyHTML", function(html, path) {
if(path && path.endsWith(".html")) {
return HTMLMinifier.minify(html, {
collapseWhitespace: true,
removeComments: true,
useShortDoctype: true,
});
}
return html;
});
eleventyConfig.addFilter("minifyCSS", function(code) {
return new CleanCSS({}).minify(code).styles;
});
eleventyConfig.addFilter("minifyJS", function(code) {
let minified = UglifyES.minify(code);
if(minified.error) {
console.log("UglifyES failed with an error: ", minified.error);
throw new Error("Javascript minification failure");
}
return minified.code;
});
return {
templateFormats: [
"html",
"md",
"njk"
],
pathPrefix: "",
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dataTemplateEngine: "njk",
passthroughFileCopy: true,
dir: {
input: ".",
includes: "_includes",
data: "_data",
output: "_site"
}
};
}