From 63d525e50c3d6ff3460e11244bfc6025804fedd6 Mon Sep 17 00:00:00 2001 From: codecalm Date: Wed, 17 Aug 2022 22:33:13 +0200 Subject: `tags.json` build --- .eleventy.js | 10 ++++++++++ src/_tags.json | 10 ---------- src/tags.liquid | 11 +++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) delete mode 100644 src/_tags.json create mode 100644 src/tags.liquid diff --git a/.eleventy.js b/.eleventy.js index 0024463e..b9f82634 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -47,6 +47,16 @@ module.exports = function(eleventyConfig) { } }); + eleventyConfig.addTemplateFormats("json"); + eleventyConfig.addExtension("json", { + outputFileExtension: 'json', + compile: async function(inputContent) { + return async () => { + return inputContent; + }; + } + }); + eleventyConfig.addCollection('icons', collection => { return collection.getFilteredByGlob('./src/icons/*.svg').sort((a, b) => { return b.name - a.name diff --git a/src/_tags.json b/src/_tags.json deleted file mode 100644 index 3e698f20..00000000 --- a/src/_tags.json +++ /dev/null @@ -1,10 +0,0 @@ ---- ---- -{ {% for icon in site.icons %} -{% assign slug-tags = icon.slug | split: '-' %}{% assign tags = slug-tags | concat: icon.tags %} "{{ icon.slug }}": { - "category": "{{ icon.category }}", - "tags": ["{{ tags | join: '", "' }}"], - "version": "{{ icon.version }}", - "unicode": "{{ icon.unicode }}" - }{% unless forloop.last %}, {% endunless %}{% endfor %} -} diff --git a/src/tags.liquid b/src/tags.liquid new file mode 100644 index 00000000..bc17a103 --- /dev/null +++ b/src/tags.liquid @@ -0,0 +1,11 @@ +--- +permalink: tags.json +--- +{ {% for icon in collections.icons %} +{% assign slug-tags = icon.fileSlug | split: '-' %}{% assign tags = slug-tags | concat: icon.data.tags %} "{{ icon.fileSlug }}": { + "category": "{{ icon.data.category }}", + "tags": ["{{ tags | join: '", "' }}"], + "version": "{{ icon.data.version }}", + "unicode": "{{ icon.data.unicode }}" + }{% unless forloop.last %}, {% endunless %}{% endfor %} +} -- cgit v1.2.1