This repository has been archived on 2023-03-14. You can view files and clone it, but cannot push or open issues or pull requests.
personal-website-old/.eleventy.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-10-18 20:58:07 +00:00
const pluginNavigation = require('@11ty/eleventy-navigation')
const htmlmin = require('html-minifier')
const markdownIt = require('markdown-it')
const markdownItAttrs = require('markdown-it-attrs')
2021-10-07 20:45:46 +00:00
const options = {
html: true,
breaks: true,
linkify: true
2021-10-18 20:58:07 +00:00
}
const markdownLib = markdownIt(options).use(markdownItAttrs)
2021-10-07 20:45:46 +00:00
2021-05-20 20:02:50 +00:00
module.exports = function (eleventyConfig) {
2021-10-18 20:58:07 +00:00
eleventyConfig.addGlobalData('username', 'Laureηt')
eleventyConfig.addPlugin(pluginNavigation)
eleventyConfig.setLibrary('md', markdownLib)
eleventyConfig.addWatchTarget('./src/scss/')
2021-05-20 20:02:50 +00:00
eleventyConfig.addPassthroughCopy({
2021-10-18 20:58:07 +00:00
'assets/': './'
})
2021-10-18 20:58:07 +00:00
if (process.env.ELEVENTY_ENV === 'prod') {
eleventyConfig.addTransform('htmlmin', function (content, outputPath) {
2021-10-07 16:31:51 +00:00
// Eleventy 1.0+: use this.inputPath and this.outputPath instead
2021-10-18 20:58:07 +00:00
if (outputPath && outputPath.endsWith('.html')) {
const minified = htmlmin.minify(content, {
2021-10-07 16:31:51 +00:00
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyJS: true,
2021-10-18 20:58:07 +00:00
minifyCSS: true
})
return minified
2021-10-07 16:31:51 +00:00
} else {
2021-10-18 20:58:07 +00:00
return content
2021-10-07 16:31:51 +00:00
}
2021-10-18 20:58:07 +00:00
})
2021-10-07 16:31:51 +00:00
}
2021-10-18 20:58:07 +00:00
eleventyConfig.addShortcode('year', () => {
const year = new Date().getFullYear()
return year.toString()
})
2021-05-20 20:02:50 +00:00
return {
2021-10-07 20:45:46 +00:00
passthroughFileCopy: true,
2021-05-20 20:02:50 +00:00
dir: {
2021-10-18 20:58:07 +00:00
input: 'src',
data: '_data',
output: '_site',
includes: '_includes'
}
2021-05-20 20:02:50 +00:00
}
2021-10-07 16:31:51 +00:00
}