@pmoreno i don’t think you should use swich tag here, after all the output is just a boolean (TRUE/FALSE). You might consider using something like this:
{% set shareicons = header_var('shareicons')|defined({'facebook': true, 'twitter': true}) %}
and then
{% if shareicons.twitter %}
{# link to share on twitter #}
{% endif %}
{% if shareicons.facebook %}
{# link to share on facebook #}
{% endif %}
or just
{% if page.header.shareicons.facebook|defined(true) %}
{# link to share on facebook #}
{% endif %}
Also, it might be better to place this configuration in the theme’s blueprint? and take a look at share.html.twig partial of the Cacti theme.
P.S. Just noticed you are the author of the Futura2021 theme
Hello @b.da.
Indeed, I am currently developing the Future2021 theme (Future fork) and I try to improve it a little more every day.
Currently, the theme has social media icons both in the left sidebar and in the footer, as well as in each blog post.
The icons on the left side are defined globally in the theme (as in the Cacti theme and others) and are used to direct the user to the social networks of the page author.
I want to use the blog article icons to share that particular article on social media. I currently have code with if statements and variables defined on the page (as you propose in your answer), and it works great:
{% for network, enabled in shareicons %}
{% if enabled is same as(true) %}
{% switch network %}
{% case 'twitter' %}
{# share link #}
{% case 'facebook' %}
{# share link #}
{% case 'whatsapp' %}
{# share link #}
{% case 'telegram' %}
{# share link #}
{% endswitch %}
{% endif %}
{% endfor %}
Not saying that this is a simplification but if change it a bit, you can use the same particle for two cases.
@b.da, your solution, apart from working very well, is elegant, just what I was looking for. I will incorporate these improvements into the next version of the Future2021 theme.