From 9c2987751f522ae470fcc81f31a8c8f0e5102dca Mon Sep 17 00:00:00 2001 From: codecalm Date: Wed, 17 Aug 2022 14:24:13 +0200 Subject: eleventy test --- .eleventy.js | 73 +++++++++++++++++++++++++++++++++++++---------- src/_data/icons.js | 5 ---- src/_includes/icon.html | 6 ++++ src/bg.svg | 2 +- src/icons/gas-station.svg | 1 - src/index.html | 16 +++++------ src/style.scss | 6 ++-- src/tags.html | 19 ++++++------ 8 files changed, 85 insertions(+), 43 deletions(-) delete mode 100644 src/_data/icons.js diff --git a/.eleventy.js b/.eleventy.js index aa0771dc..0024463e 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,24 +1,67 @@ -module.exports = function(config) { +const sass = require("sass"); +const path = require("path"); - config.addLiquidFilter('group_by', () => {}) - config.addCollection('icons', collection => - collection.getFilteredByGlob('icons/*.svg') - .sort((a, b) => { - console.log('a', a); - - return b.date - a.date - }) - ) +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: 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('', `\n `); + }; + } + }); + + eleventyConfig.addCollection('icons', collection => { + return collection.getFilteredByGlob('./src/icons/*.svg').sort((a, b) => { + return b.name - a.name + }) + }) return { + dynamicPartials: false, dir: { - input: "src", + input: 'src', - includes: "_includes", - layouts: "_layouts", - data: "_data", + includes: '_includes', + layouts: '_layouts', + data: '_data' } } -}; +} diff --git a/src/_data/icons.js b/src/_data/icons.js deleted file mode 100644 index 83aebbcb..00000000 --- a/src/_data/icons.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = function() { - return [ - 1, 2, 3, 4 - ]; -}; diff --git a/src/_includes/icon.html b/src/_includes/icon.html index 89bd3c60..ced25557 100644 --- a/src/_includes/icon.html +++ b/src/_includes/icon.html @@ -1,2 +1,8 @@ {% assign stroke = include.stroke | default: 2 %}{% assign width = 24 %}{% assign name = include.name %}{% assign icon = site.icons | where: "slug", name | first %}{% capture replace-to %} {% endcapture %}{% assign content = icon.content | replace: '', replace-to %}{{ content }} +{{ name }} +{{ params.name }} +{{ include.name }} +{{ includes.name }} +{{ include.stroke }} +{{ params.stroke }} diff --git a/src/bg.svg b/src/bg.svg index 0a184c59..c38f5578 100644 --- a/src/bg.svg +++ b/src/bg.svg @@ -1,5 +1,5 @@ --- -tags: [] +permaling: bg.svg --- diff --git a/src/icons/gas-station.svg b/src/icons/gas-station.svg index e8bc6df6..43e81e65 100644 --- a/src/icons/gas-station.svg +++ b/src/icons/gas-station.svg @@ -1,7 +1,6 @@ --- category: Map tags: [fuel, oil, cars, vehicles, shop, distributor] -category: Vehicles version: "1.14" unicode: "ec7d" --- diff --git a/src/index.html b/src/index.html index f8fc5f9f..91ed1b90 100644 --- a/src/index.html +++ b/src/index.html @@ -5,10 +5,10 @@ layout: default
- {% for icon in site.icons %} - {% assign name = icon.slug %} -
- {% include icon.html name=name %} + {% for icon in collections.icons %} + {% assign name = icon.fileSlug %} +
+ {% icon name %}
{% endfor %}
@@ -17,10 +17,10 @@ layout: default
- {% for icon in site.icons %} - {% assign name = icon.slug %} -
- {% include icon.html name=name stroke=1.25 %} + {% for icon in collections.icons %} + {% assign name = icon.fileSlug %} +
+ {% include "icon.html", name="name", stroke="1.25" %}
{% endfor %}
diff --git a/src/style.scss b/src/style.scss index 4886546d..6f32ef6d 100644 --- a/src/style.scss +++ b/src/style.scss @@ -318,14 +318,14 @@ Components width: 1.25rem; height: 1.25rem; position: absolute; - top: ($btn-form-height - 1.25rem) / 2; - right: ($btn-form-height - 1.25rem) / 2; + top: ($btn-form-height - 1.25rem) * .5; + right: ($btn-form-height - 1.25rem) * .5; stroke-width: 1.75; } &.icon-left { .icon { - left: ($btn-form-height - 1.25rem) / 2; + left: ($btn-form-height - 1.25rem) * .5; right: auto; } diff --git a/src/tags.html b/src/tags.html index 517fc27a..854c2664 100644 --- a/src/tags.html +++ b/src/tags.html @@ -5,20 +5,19 @@ permalink: tags.html
- {{ collections }} - {% assign i = 0 %} - {% for icon in icons %} + {% for icon in collections.icons %} - - - - - - + + + + + + - {% if icon.tags.size == 0 %} + {% assign tags-count = icon.data.tags | size %} + {% if tags-count == 0 %} {% assign i = i | plus: 1 %} {% endif %} {% endfor %} -- cgit v1.2.1
{% include "icon.html" name=icon.slug %}{{ icon.slug }}{{ icon.tags | join: ', ' }}{{ icon.category }}{{ icon.version }}{{ icon.unicode }}{% include "icon.html", name=icon.slug %}{{ icon.fileSlug }}{{ icon.data.tags | join: ', ' }}{{ icon.data.category }}{{ icon.data.version }}{{ icon.data.unicode }}