Eleventy-Template/.eleventy.js

34 lines
935 B
JavaScript

const markdownIt = require('markdown-it')
const markdownItAnchor = require('markdown-it-anchor')
module.exports = function(eleventyConfig) {
// Copy these static files to _site folder
eleventyConfig.addPassthroughCopy('src/assets')
eleventyConfig.addPassthroughCopy('src/manifest.json')
const md = markdownIt({ html: true, linkify: true })
md.use(markdownItAnchor, {
level: [1, 2],
permalink: markdownItAnchor.permalink.headerLink({
safariReaderFix: true,
class: 'header-anchor',
})
})
eleventyConfig.setLibrary('md', md)
eleventyConfig.setLiquidOptions({
dynamicPartials: false,
strictFilters: false
})
// asset_img shortcode
eleventyConfig.addLiquidShortcode('asset_img', (filename, alt) => {
return `<img class="my-4" src="/assets/img/posts/${filename}" alt="${alt}" />`
})
return {
markdownTemplateEngine: 'liquid',
dir: {
input: 'src',
}
}
}