feat(indieweb): add hidden h-card

This commit is contained in:
2025-04-08 19:53:34 +07:00
parent a9feece9b7
commit 4e4ad45acd
4 changed files with 127 additions and 1 deletions

View File

@@ -277,3 +277,27 @@ avatar = true
voting = true voting = true
page_author_hashes = "" # hash (or list of hashes) of the author. page_author_hashes = "" # hash (or list of hashes) of the author.
lazy_loading = true # Loads when the comments are in the viewport (using the Intersection Observer API). lazy_loading = true # Loads when the comments are in the viewport (using the Intersection Observer API).
# h-card configuration
# Will identify you on the indieweb (see https://microformats.org/wiki/h-card)
[extra.hcard]
# Enable home page h-card.
enable = true
# Add your email to the card if extra.email is set and not encoded.
with_mail = true
# Add your social links ('socials' config) to the card.
with_social_links = true
# Homepage url. Defaults to the value of 'base_url'.
homepage = "https://zlinux.ru"
avatar = "img/avator.webp"
# Display name, default to the value of 'author'.
full_name = "Zloy Linux"
# Small bio, as shown on social media profiles.
biography = "Linux Man"
#
# You can add any property from https://microformats.org/wiki/h-card#Properties
# Make sure to replace all '-' characters by '_'
# Examples:
p_nickname = "zloy_linux"
# p_locality = "Bordeaux"
p_country_name = "Russia"

View File

@@ -0,0 +1,75 @@
{%- set hcard = config.extra.hcard -%}
{% set full_name = config.author %}
{% if hcard.full_name %}
{% set full_name = hcard.full_name %}
{% endif %}
{%- set homepage = config.base_url -%}
{% if hcard.homepage %}
{%- set homepage = hcard.homepage -%}
{% endif %}
{% if hcard.enable %}
<div class="h-card hidden">
<div>
{%- if hcard.avatar -%}
<img
class="u-photo"
src="{{ get_url(path=hcard.avatar) }}"
width="200"
height="200"
alt="{{ full_name }}"
/>
{%- endif -%}
<span class="p-name" rel="me">{{ full_name }}</span>
{% if hcard.p_nickname %}
( <span class="p-nickname">{{ hcard.p_nickname }}</span> )
{% endif %}
</div>
{% if hcard.biography %}
<p class="p-note">{{ hcard.biography }}</p>
{% endif %}
{# links #}
<div>
{%- if hcard.with_mail and config.extra.email and not config.extra.encode_plaintext_email -%}
<span>
<a class="u-email" href="mailto:{{ config.extra.email | safe }}">email</a>
</span> -
{%- endif -%}
<span>
<a class="u-url u-id" href="{{ homepage }}">homepage</a>
</span> -
{%- if hcard.with_social_links and config.extra.socials %}
{% for social in config.extra.socials %}
<span>
<a class="p-url" rel="me" href="{{ social.url | safe }}">{{ social.name }}</a>
</span> -
{% endfor %}
{% endif %}
</div>
{# additional properties #}
{% set dl_started = false %}
{% for key, value in hcard %}
{% if key not in ['enable', 'with_mail', 'with_social_links', 'homepage', 'full_name', 'avatar', 'biography', 'p_nickname'] %}
{% if not dl_started %}
<dl>
{% set_global dl_started = true %}
{% endif %}
<dt>{{ key | replace(from="p_", to="") | replace(from="u_", to="") | replace(from="dt_", to="") | replace(from="_", to=" ") | capitalize }}</dt>
<dd class="{{ key | replace(from="_", to="-") }}">{{ value }}</dd>
{% endif %}
{% endfor %}
{% if dl_started %}
</dl>
{% endif %}
</div>
{% endif %}

View File

@@ -24,6 +24,9 @@
{%- endif -%} {%- endif -%}
<main {% if more_than_one_section_shown %}class="{{ first_section }}-first"{% endif %}> <main {% if more_than_one_section_shown %}class="{{ first_section }}-first"{% endif %}>
{%- if config.extra.hcard %}
{%- include "partials/hcard.html" -%}
{% endif -%}
{%- if section.extra.header %} {%- if section.extra.header %}
{%- include "partials/home_banner.html" -%} {%- include "partials/home_banner.html" -%}
{%- elif section.content -%} {%- elif section.content -%}

View File

@@ -375,3 +375,27 @@ custom_subset = true
# voting = true # voting = true
# page_author_hashes = "" # hash (or list of hashes) of the author. # page_author_hashes = "" # hash (or list of hashes) of the author.
# lazy_loading = true # Loads when the comments are in the viewport (using the Intersection Observer API). # lazy_loading = true # Loads when the comments are in the viewport (using the Intersection Observer API).
# h-card configuration
# Will identify you on the indieweb (see https://microformats.org/wiki/h-card)
[extra.hcard]
# Enable home page h-card.
enable = true
# Add your email to the card if extra.email is set and not encoded.
# with_mail = true
# Add your social links ('socials' config) to the card.
with_social_links = true
# Homepage url. Defaults to the value of 'base_url'.
# homepage = "https://myhomepage.net"
# avatar = "img/profile.webp"
# Display name, default to the value of 'author'.
# full_name = "John Doe"
# Small bio, as shown on social media profiles.
# biography = "Fond of the indieweb"
#
# You can add any property from https://microformats.org/wiki/h-card#Properties
# Make sure to replace all '-' characters by '_'
# Examples:
# p_nickname = "nickname"
# p_locality = "Bordeaux"
# p_country_name = "France"