{"size": 3037, "ext": "js", "max_stars_repo_path": ".eleventy.js", "max_stars_repo_name": "TickleThePanda/exponential-idle-guide", "max_stars_repo_stars_event_min_datetime": "2021-08-07T00:00:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T05:21:09.000Z", "max_issues_repo_path": ".eleventy.js", "max_issues_repo_name": "TickleThePanda/exponential-idle-guide", "max_issues_repo_issues_event_min_datetime": "2021-08-09T20:00:20.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-23T07:14:58.000Z", "max_forks_repo_path": ".eleventy.js", "max_forks_repo_name": "TickleThePanda/exponential-idle-guides", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": 8, "max_forks_count": null, "avg_line_length": 24.1031746032, "max_line_length": 118, "alphanum_fraction": 0.6308857425}
const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor");

const Hypher = require('hypher')
const english = require('hyphenation.en-gb');

const slugify = require('slugify');

const hypher = new Hypher(english);

const { JSDOM } = require('jsdom');

const util = require('util');

const pluginTOC = require('eleventy-plugin-toc');

const transformExcludes = [
  "_site/sitemap.xml"
];

module.exports = config => {

  const markdownItOptions = {
    html: true,
    typographer: true
  };

  const markdownItAnchorOptions = {
    permalink: true,
    slugify: s => slugify(s, {
      lower: true,
      strict: true
    }),
    permalinkClass: "direct-link",
    permalinkSymbol: "#",
    permalinkAttrs: (slug, state) => ({
      "aria-label": "Permalink: " + slug
    }),
    level: [1,2,3,4]
  };


  config.addPlugin(pluginTOC)

  config.setLibrary(
    "md",
    markdownIt(markdownItOptions)
      .use(markdownItAnchor, markdownItAnchorOptions)
      .use(require('markdown-it-mathjax')())
  );

  config.setDataDeepMerge(true);

  config.addTransform("hyphenation", (content, outputPath) => {
    if (!transformExcludes.includes(outputPath)) {

      const dom = new JSDOM(content);
      const document = dom.window.document;
      const NodeFilter = dom.window.NodeFilter;

      const filter = {
        acceptNode: n => n.parentElement.closest("pre") === null ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
      };

      const walk = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, filter);

      while (walk.nextNode()) {
        walk.currentNode.nodeValue = hypher.hyphenateText(walk.currentNode.nodeValue);
      }
      return dom.serialize();
    } else {
      return content;
    }
  });

  config.addTransform("table-wrapper", (content, outputPath) => {
    if (!transformExcludes.includes(outputPath)) {

      const dom = new JSDOM(content);
      const document = dom.window.document;
      const tables = Array.from(document.querySelectorAll('table'));

      for (let table of tables) {
        const parent = table.parentNode;

        const wrappingDiv = document.createElement("div");
        wrappingDiv.classList.add('table-wrapper');
        parent.insertBefore(wrappingDiv, table)
        wrappingDiv.appendChild(table);
      }
      return dom.serialize();
    } else {
      return content;
    }
  });

  config.addFilter("slug", s =>
    s !== undefined ?
      slugify(s, { lower: true, strict: true }) :
      "-"
  );

  config.addFilter("inspect", (s, d) =>
    util.inspect(s, {depth: d === undefined ? 2 : d})
  );

  config.addCollection("guides", function(collection) {
    return collection.getFilteredByTag("guide").sort(function(a, b) {
      return a.data.order - b.data.order;
    });
  });

  config.addGlobalData("site", { url: "https://exponential-idle-guides.netlify.app" });

  return {
    dir: {
      input: "src/view",
      data: "_data",
      output: "_site"
    },
    markdownTemplateEngine: "njk"
  };
}


