aboutsummaryrefslogtreecommitdiff
path: root/.eleventy.js
blob: d5f7c388771342ab49bc7eae1787ccad160ac515 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const sass = require("sass");
const path = require("path");


module.exports = function(eleventyConfig) {

  eleventyConfig.addShortcode("icon", function(name) {
    return name
  });


  eleventyConfig.addLiquidFilter('group_by', () => {
  })

  eleventyConfig.addLiquidFilter('inspect', (i) => {
    console.log('i', i);
  })

  eleventyConfig.addTemplateFormats("scss");
  eleventyConfig.addExtension("scss", {
    outputFileExtension: 'css',
    compile: async function(inputContent) {
      let result = sass.compileString(inputContent);

      return async () => {
        return result.css;
      };
    }
  });

  eleventyConfig.addTemplateFormats("svg");
  eleventyConfig.addExtension("svg", {
    outputFileExtension: 'svg',
    compileOptions: {
      permalink: false
      // permalink: function(contents, inputPath) {
      //   const basename = path.basename(inputPath);
      //   return `icons/${basename}`;
      // }
    },
    compile: async (inputContent, inputPath) => {

      return async () => {
        const basename = path.basename(inputPath, '.svg');

        return inputContent.replace('<svg>', `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-${basename}" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">\n  <path stroke="none" d="M0 0h24v24H0z" fill="none"/>`);
      };
    }
  });


  eleventyConfig.addCollection('icons', collection => {
    return collection.getFilteredByGlob('./src/icons/*.svg').sort((a, b) => {
      return b.name - a.name
    })
  })

  return {
    dynamicPartials: false,
    dir: {
      input: 'src',

      includes: '_includes',
      layouts: '_layouts',
      data: '_data'
    }
  }

}