Skip to content

Commit

Permalink
feat: support Simple Icons for social icons
Browse files Browse the repository at this point in the history
  • Loading branch information
st1020 committed May 19, 2024
1 parent 01e0b32 commit 968ba41
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 24 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pnpm-lock.yaml
templates/macros.html
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ avatar_url = "icons/github.svg"
avatar_invert = true

# The social icons below the profile on the home page.
# The `name` should be the file name of static/icons/*.svg or the icon name of https://simpleicons.org/
[[extra.profile.social]]
name = "github"
url = "https://github.com/st1020/kita"
Expand Down
2 changes: 0 additions & 2 deletions static/icons/codeberg.svg

This file was deleted.

4 changes: 0 additions & 4 deletions static/icons/goodreads.svg

This file was deleted.

1 change: 0 additions & 1 deletion static/icons/instagram.svg

This file was deleted.

1 change: 0 additions & 1 deletion static/icons/linkedin.svg

This file was deleted.

1 change: 0 additions & 1 deletion static/icons/mastodon.svg

This file was deleted.

6 changes: 0 additions & 6 deletions static/icons/stackoverflow.svg

This file was deleted.

6 changes: 0 additions & 6 deletions static/icons/telegram.svg

This file was deleted.

1 change: 0 additions & 1 deletion static/icons/twitter.svg

This file was deleted.

1 change: 1 addition & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% import "macros.html" as macros %}
<!doctype html>
<html class="not-ready lg:text-base" lang="{{ lang }}">
{% include "partials/head.html" %}
Expand Down
8 changes: 8 additions & 0 deletions templates/macros.html
Original file line number Diff line number Diff line change
@@ -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 -%}
3 changes: 2 additions & 1 deletion templates/partials/head.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% import "macros.html" as macros %}
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Expand Down Expand Up @@ -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 %}
Expand Down
2 changes: 1 addition & 1 deletion templates/partials/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1 class="mb-2 text-3xl font-bold">{{ config.extra.profile.name }}</h1>
{% 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 %}"
Expand Down

0 comments on commit 968ba41

Please sign in to comment.