Skip to content

Commit 968ba41

Browse files
committed
feat: support Simple Icons for social icons
1 parent 01e0b32 commit 968ba41

14 files changed

+14
-24
lines changed

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pnpm-lock.yaml
2+
templates/macros.html

config.toml

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ avatar_url = "icons/github.svg"
7979
avatar_invert = true
8080

8181
# The social icons below the profile on the home page.
82+
# The `name` should be the file name of static/icons/*.svg or the icon name of https://simpleicons.org/
8283
[[extra.profile.social]]
8384
name = "github"
8485
url = "https://github.com/st1020/kita"

static/icons/codeberg.svg

-2
This file was deleted.

static/icons/goodreads.svg

-4
This file was deleted.

static/icons/instagram.svg

-1
This file was deleted.

static/icons/linkedin.svg

-1
This file was deleted.

static/icons/mastodon.svg

-1
This file was deleted.

static/icons/stackoverflow.svg

-6
This file was deleted.

static/icons/telegram.svg

-6
This file was deleted.

static/icons/twitter.svg

-1
This file was deleted.

templates/index.html

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

templates/macros.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{%- macro get_social_icon(icon) -%}
2+
{%- set meta = get_image_metadata(path="/static/icons/" ~ icon ~ ".svg", allow_missing=true) -%}
3+
{%- if meta -%}
4+
{{- get_url(path="icons/" ~ icon ~ ".svg") -}}
5+
{%- else -%}
6+
{{- "https://cdn.jsdelivr.net/npm/simple-icons/icons/" ~ icon ~ ".svg" -}}
7+
{%- endif -%}
8+
{%- endmacro get_social_icon -%}

templates/partials/head.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% import "macros.html" as macros %}
12
<head>
23
<meta charset="utf-8" />
34
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
@@ -68,7 +69,7 @@
6869
{% if config.extra.profile.social %}
6970
<!---->
7071
{% for social in config.extra.profile.social %}
71-
<link rel="preload" as="image" href="{{ get_url(path=`icons/` ~ social.name ~ `.svg`) }}" />
72+
<link rel="preload" as="image" href="{{ macros::get_social_icon(icon=social.name) }}" />
7273
{% endfor %}
7374
<!---->
7475
{% endif %}

templates/partials/profile.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h1 class="mb-2 text-3xl font-bold">{{ config.extra.profile.name }}</h1>
2424
{% for social in config.extra.profile.social %}
2525
<a
2626
class="primary-link h-8 w-8 text-[0] [background:var(--url)_center_center/cover_no-repeat]"
27-
style="--url: url(./icons/{{ social.name }}.svg)"
27+
style="--url: url({{ macros::get_social_icon(icon=social.name) }})"
2828
href="{{ social.url | replace(from=`$BASE_URL`, to=config.base_url) | safe }}"
2929
target="_blank"
3030
rel="{% if social.name == `rss` %}alternate{% else %}me{% endif %}"

0 commit comments

Comments
 (0)