Added name attribute to social links and improved defaults

This commit is contained in:
squidfunk 2020-05-03 14:14:59 +02:00
parent 1b72c9f17d
commit db7c28b20e
3 changed files with 16 additions and 6 deletions

View File

@ -614,6 +614,10 @@ extra:
link: https://linkedin.com/in/squidfunk link: https://linkedin.com/in/squidfunk
``` ```
By default, the link `title` will be set to the domain name, e.g. _github.com_.
If you want to set a discernable name, e.g., to improve your Lighthouse score,
you can set the `name` attribute on each social link.
[21]: #icons [21]: #icons
### Adding a Web App Manifest ### Adding a Web App Manifest

View File

@ -4,9 +4,12 @@
{% if config.extra.social %} {% if config.extra.social %}
<div class="md-footer-social"> <div class="md-footer-social">
{% for social in config.extra.social %} {% for social in config.extra.social %}
{% set _,rest = social.link.split("//") %} {% set title = social.name %}
{% set domain = rest.split("/")[0] %} {% if not title and "//" in social.link %}
<a href="{{ social.link }}" target="_blank" rel="noopener" title="{{ domain }}" class="md-footer-social__link"> {% set _,url = social.link.split("//") %}
{% set title = url.split("/")[0] %}
{% endif %}
<a href="{{ social.link }}" target="_blank" rel="noopener" title="{{ title }}" class="md-footer-social__link">
{% include ".icons/" ~ social.icon ~ ".svg" %} {% include ".icons/" ~ social.icon ~ ".svg" %}
</a> </a>
{% endfor %} {% endfor %}

View File

@ -24,12 +24,15 @@
{% if config.extra.social %} {% if config.extra.social %}
<div class="md-footer-social"> <div class="md-footer-social">
{% for social in config.extra.social %} {% for social in config.extra.social %}
{% set _,rest = social.link.split("//") %} {% set title = social.name %}
{% set domain = rest.split("/")[0] %} {% if not title and "//" in social.link %}
{% set _,url = social.link.split("//") %}
{% set title = url.split("/")[0] %}
{% endif %}
<a <a
href="{{ social.link }}" href="{{ social.link }}"
target="_blank" rel="noopener" target="_blank" rel="noopener"
title="{{ domain }}" title="{{ title }}"
class="md-footer-social__link" class="md-footer-social__link"
> >
{% include ".icons/" ~ social.icon ~ ".svg" %} {% include ".icons/" ~ social.icon ~ ".svg" %}