summaryrefslogtreecommitdiff
path: root/eleventy.config.js
blob: a12047a395fa4b15cbc68ffe8909398c7ecac5c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pluginRss from "@11ty/eleventy-plugin-rss";
import markdownIt from "markdown-it";
import { outdent } from "outdent";

export default function(eleventyConfig) {
  eleventyConfig.addPlugin(pluginRss);

  eleventyConfig.addPassthroughCopy("src/assets");
  eleventyConfig.addPassthroughCopy("src/toys");

  // Configure markdown-it
  const md = markdownIt({
    html: true,
    breaks: false,
    linkify: true
  });

  eleventyConfig.setLibrary("md", md);

  // Add markdown shortcode
  eleventyConfig.addPairedShortcode("markdown", (content) => {
    return md.render(outdent`${content}`);
  });

  // Add posts collection
  eleventyConfig.addCollection("posts", (collectionApi) => {
    return collectionApi.getFilteredByGlob("src/posts/**/*.md");
  });

  return {
    dir: {
      input: "src",
      output: "_site",
      includes: "_includes",
      layouts: "_layouts"
    },
    markdownTemplateEngine: "njk",
    htmlTemplateEngine: "njk"
  };
}