feat: Convert filename to alt text

This commit is contained in:
marleyrae 2023-06-08 16:43:45 -07:00
parent 3f43316a58
commit ca2e680f7f
4 changed files with 11 additions and 2 deletions

View file

@ -39,5 +39,11 @@ module.exports = function (eleventyConfig) {
},
})
// Convert img filename to alt text
eleventyConfig.addFilter('toAlt', (text) => {
const basename = text.split('.')
return basename[0].replace(/_/g, ' ')
})
return {dir: {input: 'src', output: 'dist'}}
}

View file

@ -5,7 +5,10 @@ layout: layout.liquid
{% for source in buttons %}
{% for button in source[1] %}
<a href="{{ credits[source[0]] }}" target="_blank">
<img src="/collections/images/buttons/{{ source[0] }}/{{ button }}" alt="{{ source[0] }}">
<img
src="/collections/images/buttons/{{ source[0] }}/{{ button }}"
alt="{{ button | toAlt }}"
>
</a>
{% endfor %}
{% endfor %}

View file

@ -68,6 +68,6 @@ module.exports = async function () {
}
collections.credits = credits
console.log(collections.buttons)
return collections
}

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB