Allow setting favicon per page/section

This commit is contained in:
daudix
2024-09-18 03:21:34 +03:00
parent 3603618b4d
commit 880a323b27
4 changed files with 33 additions and 9 deletions

View File

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `h1` with page/section title by default. - Add `h1` with page/section title by default.
- Add ability to set accent color per page/section. - Add ability to set accent color per page/section.
- Add ability to set default theme per page/section. - Add ability to set default theme per page/section.
- Add ability to set favicon/emoji per page/section.
- Add ability to set metadata card per page/section. - Add ability to set metadata card per page/section.
- Add active state to footer's "Powered by" links. - Add active state to footer's "Powered by" links.
- Add active state to footnotes' go back button. - Add active state to footnotes' go back button.

View File

@ -0,0 +1,28 @@
<link rel="icon" type="image/png" href="
{%- if page.extra.favicon -%}
{{ get_url(path=page.colocated_path ~ page.extra.favicon) }}
{%- elif section.extra.favicon -%}
{{ get_url(path=section.colocated_path ~ section.extra.favicon) }}
{%- else -%}
{{ get_url(path='favicon.png') }}
{%- endif -%}" />
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="
{%- if page.extra.apple_touch_icon -%}
{{ get_url(path=page.colocated_path ~ page.extra.apple_touch_icon) }}
{%- elif section.extra.apple_touch_icon -%}
{{ get_url(path=section.colocated_path ~ section.extra.apple_touch_icon) }}
{%- else -%}
{{ get_url(path='apple-touch-icon.png') }}
{%- endif -%}" />
{%- if page.extra.emoji_favicon or section.extra.emoji_favicon or config.extra.emoji_favicon %}
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext x='-.07em' y='.89em' font-size='90'%3E
{%- if page.extra.emoji_favicon -%}
{{ page.extra.emoji_favicon | truncate(length=1, end='') }}
{%- elif section.extra.emoji_favicon -%}
{{ section.extra.emoji_favicon | truncate(length=1, end='') }}
{%- else -%}
{{ config.extra.emoji_favicon | truncate(length=1, end='') }}
{%- endif -%}%3C/text%3E%3C/svg%3E">
{%- endif %}

View File

@ -23,12 +23,7 @@
<link rel="me" href="https://{{ config.extra.comments.host }}/@{{ config.extra.comments.user }}" /> <link rel="me" href="https://{{ config.extra.comments.host }}/@{{ config.extra.comments.user }}" />
{%- endif %} {%- endif %}
<link rel="icon" type="image/png" href="{{ get_url(path='favicon.png') }}" /> {%- include "partials/favicon.html" %}
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="{{ get_url(path='apple-touch-icon.png') }}" />
{%- if config.extra.emoji_favicon %}
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext x='-.07em' y='.89em' font-size='90'%3E{{ config.extra.emoji_favicon | truncate(length=1, end='') }}%3C/text%3E%3C/svg%3E">
{%- endif %}
{%- if config.generate_feeds and config.feed_filenames %} {%- if config.generate_feeds and config.feed_filenames %}
{%- for feed in config.feed_filenames %} {%- for feed in config.feed_filenames %}

View File

@ -115,10 +115,10 @@
{%- for feed in config.feed_filenames %} {%- for feed in config.feed_filenames %}
<li> <li>
<a href="{{ get_url(path=feed, lang=lang) }}" rel="{{ rel_attributes }}"> <a href="{{ get_url(path=feed, lang=lang) }}" rel="{{ rel_attributes }}">
{%- if feed == "rss.xml" -%} {%- if feed == "atom.xml" -%}
RSS
{%- elif feed == "atom.xml" -%}
Atom Atom
{%- else -%}
RSS
{%- endif -%} {%- endif -%}
</a> </a>
</li> </li>