feat: support Simple Icons for social icons

This commit is contained in:
st1020 2024-05-19 18:22:56 +08:00
parent 01e0b32dcf
commit 968ba4178a
14 changed files with 14 additions and 24 deletions

View file

@ -1,3 +1,4 @@
{% import "macros.html" as macros %}
<!doctype html>
<html class="not-ready lg:text-base" lang="{{ lang }}">
{% include "partials/head.html" %}

8
templates/macros.html Normal file
View file

@ -0,0 +1,8 @@
{%- macro get_social_icon(icon) -%}
{%- set meta = get_image_metadata(path="/static/icons/" ~ icon ~ ".svg", allow_missing=true) -%}
{%- if meta -%}
{{- get_url(path="icons/" ~ icon ~ ".svg") -}}
{%- else -%}
{{- "https://cdn.jsdelivr.net/npm/simple-icons/icons/" ~ icon ~ ".svg" -}}
{%- endif -%}
{%- endmacro get_social_icon -%}

View file

@ -1,3 +1,4 @@
{% import "macros.html" as macros %}
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
@ -68,7 +69,7 @@
{% if config.extra.profile.social %}
<!---->
{% for social in config.extra.profile.social %}
<link rel="preload" as="image" href="{{ get_url(path=`icons/` ~ social.name ~ `.svg`) }}" />
<link rel="preload" as="image" href="{{ macros::get_social_icon(icon=social.name) }}" />
{% endfor %}
<!---->
{% endif %}

View file

@ -24,7 +24,7 @@
{% for social in config.extra.profile.social %}
<a
class="primary-link h-8 w-8 text-[0] [background:var(--url)_center_center/cover_no-repeat]"
style="--url: url(./icons/{{ social.name }}.svg)"
style="--url: url({{ macros::get_social_icon(icon=social.name) }})"
href="{{ social.url | replace(from=`$BASE_URL`, to=config.base_url) | safe }}"
target="_blank"
rel="{% if social.name == `rss` %}alternate{% else %}me{% endif %}"