text: const { DateTime } = require("luxon");
  const navigationPlugin = require('@11ty/eleventy-navigation')
  const rssPlugin = require('@11ty/eleventy-plugin-rss')
  
  module.exports = function(eleventyConfig) {
  
  
    function filterTagList(tags) {
      return (tags || []).filter(tag => ["all", "nav"].indexOf(tag) === -1);
    }
    eleventyConfig.setDataDeepMerge(true);
  
    function filterTagList(tags) {
      return (tags || []).filter(tag => ["all", "nav", "post", "posts"].indexOf(tag) === -1);
    }
  
    eleventyConfig.addFilter("filterTagList", filterTagList)
  
    eleventyConfig.addCollection("tagList", collection => {
      const tagsObject = {}
      collection.getAll().forEach(item => {
        if (!item.data.tags) return;
        item.data.tags
          .filter(tag => !['post', 'all'].includes(tag))
          .forEach(tag => {
            if(typeof tagsObject[tag] === 'undefined') {
              tagsObject[tag] = 1
            } else {
              tagsObject[tag] += 1
            }
          });
      });
  
      const tagList = []
      Object.keys(tagsObject).forEach(tag => {
        tagList.push({ tagName: tag, tagCount: tagsObject[tag] })
      })
      return tagList.sort((a, b) => b.tagCount - a.tagCount)
  
    });
  
  
    // Add a filter using the Config API
    eleventyConfig.addWatchTarget("./src/scss/");
    eleventyConfig.setBrowserSyncConfig({
      reloadDelay: 400
    });
  
    eleventyConfig.addFilter("readableDate", dateObj => {
      console.log(dateObj)
      return DateTime.fromJSDate(dateObj, {
        zone: 'utc'
      }).toFormat("dd LLL yyyy");
    });
  
    // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
    eleventyConfig.addFilter('htmlDateString', (dateObj) => {
      return DateTime.fromJSDate(dateObj, {
        zone: 'utc'
      }).toFormat('yyyy-LL-dd');
    });
    return {
      dir: {
        input: "src",
        output: "dev"
      }
    };
  
  };
  