text: const { DateTime } = require("luxon");
  const CleanCSS = require("clean-css");
  const UglifyJS = require("uglify-es");
  const htmlmin = require("html-minifier");
  const slugify = require("slugify");
  const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
  const pluginSEO = require("eleventy-plugin-seo");
  
  module.exports = function(eleventyConfig) {
  
    // Eleventy Navigation https://www.11ty.dev/docs/plugins/navigation/
    eleventyConfig.addPlugin(eleventyNavigationPlugin);
  
    eleventyConfig.addPlugin(pluginSEO, {
      title: "Tapestry Linens & Decor",
      description: "Create a unique and stunning event by accessing Tapestry's distinctive tablecloths, specialty linen, centerpieces, linens, decor, and floral design rentals.",
      url: "https://tapestrylinens.com",
      author: "Tapestry Linens and Cerberus Agency",
      image: "/static/img/fountain-pinklight-1000.jpg",
      options: {
        titleDivider: "|",
        imageWithBaseUrl: true
      }
    });
  
    // Merge data instead of overriding
    // https://www.11ty.dev/docs/data-deep-merge/
    eleventyConfig.setDataDeepMerge(true);
  
    // Date formatting (human readable)
    eleventyConfig.addFilter("readableDate", dateObj => {
      return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy");
    });
  
    // Date formatting (machine readable)
    eleventyConfig.addFilter("machineDate", dateObj => {
      return DateTime.fromJSDate(dateObj).toFormat("yyyy-MM-dd");
    });
  
    // Minify CSS
    eleventyConfig.addFilter("cssmin", function(code) {
      return new CleanCSS({}).minify(code).styles;
    });
  
    // Minify JS
    eleventyConfig.addFilter("jsmin", function(code) {
      let minified = UglifyJS.minify(code);
      if (minified.error) {
        console.log("UglifyJS error: ", minified.error);
        return code;
      }
      return minified.code;
    });
  
    // Minify HTML output
    eleventyConfig.addTransform("htmlmin", function(content, outputPath) {
      if (outputPath.indexOf(".html") > -1) {
        let minified = htmlmin.minify(content, {
          useShortDoctype: true,
          removeComments: true,
          collapseWhitespace: true
        });
        return minified;
      }
      return content;
    });
  
    // Universal slug filter strips unsafe chars from URLs
    eleventyConfig.addFilter("slugify", function(str) {
      return slugify(str, {
        lower: true,
        replacement: "-",
        remove: /[*+~.·,()'"`´%!?¿:@]/g
      });
    });
  
    // Don't process folders with static assets e.g. images
    eleventyConfig.addPassthroughCopy("favicon.ico");
    eleventyConfig.addPassthroughCopy("static/img");
    eleventyConfig.addPassthroughCopy("admin");
    eleventyConfig.addPassthroughCopy("_includes/assets/");
  
    /* Markdown Plugins */
    let markdownIt = require("markdown-it");
    let markdownItAnchor = require("markdown-it-anchor");
    let options = {
      html: true,
      breaks: true,
      linkify: true
    };
    let opts = {
      permalink: false
    };
  
    eleventyConfig.setLibrary("md", markdownIt(options)
      .use(markdownItAnchor, opts)
    );
  
    return {
      templateFormats: ["md", "njk", "html", "liquid"],
  
      // If your site lives in a different subdirectory, change this.
      // Leading or trailing slashes are all normalized away, so don’t worry about it.
      // If you don’t have a subdirectory, use "" or "/" (they do the same thing)
      // This is only used for URLs (it does not affect your file structure)
      pathPrefix: "/",
  
      markdownTemplateEngine: "liquid",
      htmlTemplateEngine: "njk",
      dataTemplateEngine: "njk",
      dir: {
        input: ".",
        includes: "_includes",
        data: "_data",
        output: "_site"
      }
    };
  };
  