64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
const pluginRss = require('@11ty/eleventy-plugin-rss')
|
|
const pluginToc = require('eleventy-plugin-nesting-toc')
|
|
const pluginSyntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
|
|
|
|
// extra features for markdown
|
|
const markdownIt = require('markdown-it')
|
|
const abbrs = require('markdown-it-abbr')
|
|
const anchors = require('markdown-it-anchor')
|
|
const footnotes = require('markdown-it-footnote')
|
|
const lazyLoading = require('@junwatu/markdown-it-lazy-loading')
|
|
|
|
const { DateTime } = require('luxon')
|
|
const header = require('./src/_includes/filters/header')
|
|
|
|
module.exports = function (config) {
|
|
config.addWatchTarget('./src/posts/drafts/*.md')
|
|
config.setServerOptions({
|
|
watch: [
|
|
'./_site/assets/*.css'
|
|
]
|
|
})
|
|
|
|
config.addPlugin(pluginRss)
|
|
config.addPlugin(pluginToc)
|
|
config.addPlugin(pluginSyntaxHighlight)
|
|
|
|
config.addPassthroughCopy('src/robots.txt')
|
|
config.addPassthroughCopy('src/assets/key.txt')
|
|
config.addPassthroughCopy('src/assets/prism-base16-ateliersulphurpool.light.css')
|
|
config.addPassthroughCopy('src/posts/**/*.{jpeg,jpg,png,webp}')
|
|
|
|
// configure markdown
|
|
const mdOptions = {
|
|
html: true,
|
|
breaks: true,
|
|
linkify: true
|
|
}
|
|
|
|
config.setLibrary("md",
|
|
markdownIt(mdOptions)
|
|
.use(abbrs)
|
|
.use(anchors)
|
|
.use(footnotes)
|
|
.use(lazyLoading, { img: 'lazy' })
|
|
)
|
|
|
|
// template filters
|
|
|
|
// format dates as YYYY-MM-DD
|
|
config.addFilter('toISODate', date => DateTime.fromJSDate(date).toISODate())
|
|
|
|
// 10print homage
|
|
config.addFilter('header', header)
|
|
|
|
// returns classes to be used on <body>, given a page's url
|
|
config.addFilter('pageClasses', url => {
|
|
const segments = url.split('/').filter(s => s)
|
|
return segments.length ? segments.join(' ') : 'home'
|
|
})
|
|
|
|
return {
|
|
markdownTemplateEngine: "njk"
|
|
}
|
|
}
|