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
2022-01-21 15:12:21 +01:00

54 lines
1.4 KiB
JavaScript

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