64 lines
1.7 KiB
JavaScript
64 lines
1.7 KiB
JavaScript
import pluginRss from '@11ty/eleventy-plugin-rss'
|
|
import pluginToc from 'eleventy-plugin-nesting-toc'
|
|
import pluginSyntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight'
|
|
|
|
// extra features for markdown
|
|
import markdownIt from 'markdown-it'
|
|
import abbrs from 'markdown-it-abbr'
|
|
import anchors from 'markdown-it-anchor'
|
|
import footnotes from 'markdown-it-footnote'
|
|
import lazyLoading from '@junwatu/markdown-it-lazy-loading'
|
|
|
|
import { DateTime } from 'luxon'
|
|
import header from './src/_includes/filters/header.js'
|
|
|
|
export default 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"
|
|
}
|
|
}
|