Add alt text support to built in index image and author avatars.

Adds `image_alt` for index's `image` and `avatar_alt` for both the
default_author's `avatar` and any page's author `avatar`. For symmetry
with their "parent" picture, `index.image_alt` and
`default_author.avatar_alt` are defaulted and assumed to exist, while
`page.author.avatar_alt` is not assumed to exist, like its parent
`page.author.avatar_alt`.
This commit is contained in:
Guillem Martinez Salvador 2022-01-28 19:16:55 -05:00
parent bfa42d26b8
commit 15d2f3bd8b
6 changed files with 11 additions and 7 deletions

View file

@ -73,10 +73,12 @@ items = [
[extra.index] [extra.index]
title = "Main title" title = "Main title"
image = "https://via.placeholder.com/200" image = "https://via.placeholder.com/200"
image_alt = "Placeholder text describing the index's image."
[extra.default_author] [extra.default_author]
name = "John Doe" name = "John Doe"
avatar = "https://via.placeholder.com/200" avatar = "https://via.placeholder.com/200"
avatar_alt = "Placeholder text describing the default author's avatar."
[extra.social] [extra.social]
github = "https://github.com/johndoe" github = "https://github.com/johndoe"

View file

@ -54,11 +54,11 @@
{% if page.extra.author.name %} {% if page.extra.author.name %}
<span class="ml-1">{{ page.extra.author.name }}</span> <span class="ml-1">{{ page.extra.author.name }}</span>
{% if page.extra.author.avatar %} {% if page.extra.author.avatar %}
<img class="rounded-full h-9 w-9 ml-1" src="{{ page.extra.author.avatar }}"> <img class="rounded-full h-9 w-9 ml-1" src="{{ page.extra.author.avatar }}"{% if page.extra.author.avatar_alt %} alt="{{ page.extra.author.avatar_alt }}"{% endif %}>
{% endif %} {% endif %}
{% else %} {% else %}
<span class="ml-1">{{ config.extra.default_author.name }}</span> <span class="ml-1">{{ config.extra.default_author.name }}</span>
<img class="rounded-full h-9 w-9 ml-1" src="{{ config.extra.default_author.avatar }}"> <img class="rounded-full h-9 w-9 ml-1" src="{{ config.extra.default_author.avatar }}" alt="{{ config.extra.default_author.avatar_alt }}">
{% endif %} {% endif %}
</span> </span>
</div> </div>

View file

@ -5,7 +5,7 @@
<h1 class="text-xl text-bold"> <h1 class="text-xl text-bold">
{{ config.extra.index.title }} {{ config.extra.index.title }}
</h1> </h1>
<img class="rounded-full h-40 w-40" src="{{ config.extra.index.image }}" alt=""> <img class="rounded-full h-40 w-40" src="{{ config.extra.index.image }}" alt="{{ config.extra.index.image_alt }}">
<div class="flex flex-wrap space-x-4 mt-7"> <div class="flex flex-wrap space-x-4 mt-7">
{% if config.extra.social.github %} {% if config.extra.social.github %}
<a href="{{config.extra.social.github}}" target="_blank"> <a href="{{config.extra.social.github}}" target="_blank">

View file

@ -49,11 +49,11 @@
{% if page.extra.author.name %} {% if page.extra.author.name %}
<span class="ml-1">{{ page.extra.author.name }}</span> <span class="ml-1">{{ page.extra.author.name }}</span>
{% if page.extra.author.avatar %} {% if page.extra.author.avatar %}
<img class="rounded-full h-9 w-9 ml-1" src="{{ page.extra.author.avatar }}"> <img class="rounded-full h-9 w-9 ml-1" src="{{ page.extra.author.avatar }}"{% if page.extra.author.avatar_alt %} alt="{{ page.extra.author.avatar_alt }}"{% endif %}>
{% endif %} {% endif %}
{% else %} {% else %}
<span class="ml-1">{{ config.extra.default_author.name }}</span> <span class="ml-1">{{ config.extra.default_author.name }}</span>
<img class="rounded-full h-9 w-9 ml-1" src="{{ config.extra.default_author.avatar }}"> <img class="rounded-full h-9 w-9 ml-1" src="{{ config.extra.default_author.avatar }}" alt="{{ config.extra.default_author.avatar_alt }}">
{% endif %} {% endif %}
</span> </span>
</div> </div>

View file

@ -54,11 +54,11 @@
{% if page.extra.author.name %} {% if page.extra.author.name %}
<span class="ml-1">{{ page.extra.author.name }}</span> <span class="ml-1">{{ page.extra.author.name }}</span>
{% if page.extra.author.avatar %} {% if page.extra.author.avatar %}
<img class="rounded-full h-9 w-9 ml-1" src="{{ page.extra.author.avatar }}"> <img class="rounded-full h-9 w-9 ml-1" src="{{ page.extra.author.avatar }}"{% if page.extra.author.avatar_alt %} alt="{{ page.extra.author.avatar_alt }}"{% endif %}>
{% endif %} {% endif %}
{% else %} {% else %}
<span class="ml-1">{{ config.extra.default_author.name }}</span> <span class="ml-1">{{ config.extra.default_author.name }}</span>
<img class="rounded-full h-9 w-9 ml-1" src="{{ config.extra.default_author.avatar }}"> <img class="rounded-full h-9 w-9 ml-1" src="{{ config.extra.default_author.avatar }}" alt="{{ config.extra.default_author.avatar_alt }}">
{% endif %} {% endif %}
</span> </span>
</div> </div>

View file

@ -73,10 +73,12 @@ items = [
[extra.index] [extra.index]
title = "Main title" title = "Main title"
image = "https://via.placeholder.com/200" image = "https://via.placeholder.com/200"
image_alt = "Placeholder text describing the index's image."
[extra.default_author] [extra.default_author]
name = "John Doe" name = "John Doe"
avatar = "https://via.placeholder.com/200" avatar = "https://via.placeholder.com/200"
avatar_alt = "Placeholder text describing the default author's avatar."
[extra.social] [extra.social]
github = "https://github.com/johndoe" github = "https://github.com/johndoe"