Add shortcode for Gitea icons

This commit is contained in:
n 2021-05-14 22:59:06 +09:00
parent 13aaa5dae2
commit aa5ed02490
3 changed files with 28 additions and 2 deletions

View file

@ -9,6 +9,15 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("fonts")
eleventyConfig.addShortcode("fas_icon", function(name) { return `<span class="fas fa-${name}"></span>` })
// List of icons: https://codeberg.org/Codeberg/gitea/src/branch/codeberg/public/img/svg
eleventyConfig.addShortcode("gitea_icon", function(name) {
const fetch = require('node-fetch');
fetch(`https://codeberg.org/img/svg/${name}.svg`)
.then(res => res.text())
.then(body => {return svg = body;});
return svg
})
return {
dir: {

18
package-lock.json generated
View file

@ -7,7 +7,8 @@
"devDependencies": {
"@11ty/eleventy": "^0.12.1",
"@11ty/eleventy-navigation": "^0.1.6",
"@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1"
"@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1",
"node-fetch": "^2.6.1"
}
},
"node_modules/@11ty/dependency-tree": {
@ -2246,6 +2247,15 @@
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true
},
"node_modules/node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true,
"engines": {
"node": "4.x || >=6.0.0"
}
},
"node_modules/nopt": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz",
@ -5644,6 +5654,12 @@
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true
},
"nopt": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz",

View file

@ -10,6 +10,7 @@
"devDependencies": {
"@11ty/eleventy": "^0.12.1",
"@11ty/eleventy-navigation": "^0.1.6",
"@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1"
"@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1",
"node-fetch": "^2.6.1"
}
}