const Nunjucks = require('nunjucks'); const nunjucksDate = require('nunjucks-date'); const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight'); const markdownIt = require('markdown-it'); const markdownItClass = require('@toycode/markdown-it-class'); const markdownClassMapping = { h1: ['text-6xl', 'mt-6', 'text-pink'], h2: ['text-3xl', 'mt-6', 'text-text'], h3: ['text-2xl', 'mt-4', 'text-text'], h4: ['text-xl', 'mt-2', 'text-text'], h5: ['text-lg', 'mt-2', 'text-text'], h6: ['font-bold', 'mt-2', 'text-text'], blockquote: ['border-l-2', 'border-lavender', 'px-4', 'pt-4', 'pb-px', 'my-8', 'bg-base'], a: ['link'], s: ['text-red'], p: ['mb-4', 'text-text', 'leading-7'], strong: ['font-normal', 'text-yellow'], em: ['italic', 'text-green'], img: ['max-w-full', 'rounded-lg', 'max-h-600px'], ul: ['list-disc', 'ml-4'], }; module.exports = function(eleventyConfig) { let nunjucksEnvironment = new Nunjucks.Environment( new Nunjucks.FileSystemLoader("_includes") ); nunjucksDate.setDefaultFormat('MMMM Do, YYYY'); nunjucksDate.install(nunjucksEnvironment); eleventyConfig.addPlugin(syntaxHighlight); const md = markdownIt({ linkify: true, html: true }); md.use(markdownItClass, markdownClassMapping); eleventyConfig.setLibrary('md', md); eleventyConfig.addPassthroughCopy('img'); eleventyConfig.addPassthroughCopy('files'); eleventyConfig.addCollection( "pinned", collection => collection.getAllSorted().filter(item => item.data.pinned), ); eleventyConfig.addFilter('markdown', (value) => { const md = markdownIt({ linkify: true, html: true }); md.use(markdownItClass, markdownClassMapping); return md.render(value); }); eleventyConfig.setLibrary('njk', nunjucksEnvironment); };