✨ feat: Convert filename to alt text
This commit is contained in:
parent
3f43316a58
commit
ca2e680f7f
4 changed files with 11 additions and 2 deletions
|
@ -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'}}
|
||||
}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -68,6 +68,6 @@ module.exports = async function () {
|
|||
}
|
||||
|
||||
collections.credits = credits
|
||||
console.log(collections.buttons)
|
||||
|
||||
return collections
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in a new issue