Skip to content

Commit

Permalink
add theme option to select a custom favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
chraebsli committed Aug 20, 2024
1 parent 44c5996 commit cf14671
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions languages/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ THEME_LOCAL:
GRID_MD: Mittel
HEADER:
TITLE: Header Standards
FAVICON:
LABEL: Benutzerdefiniertes Favicon
DESCRIPTION: Wird verwendet anstelle des Standard Favicons `theme://images/favicon.png`
CUSTOM_LOGO:
LABEL: Benutzerdefiniertes Logo
DESCRIPTION: Wird verwendet anstelle des Standardlogos `theme://images/grav-logo.svg`
Expand Down
3 changes: 3 additions & 0 deletions languages/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ THEME_LOCAL:
GRID_MD: Medium
HEADER:
TITLE: Header Defaults
FAVICON:
LABEL: Custom favicon
DESCRIPTION: Will be used instead of default favicon `theme://images/favicon.png`
CUSTOM_LOGO:
LABEL: Custom Logo
DESCRIPTION: Will be used instead of default logo `theme://images/grav-logo.svg`
Expand Down
21 changes: 21 additions & 0 deletions templates/partials/base.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
{% extends '@quark-open-publishing/partials/base.html.twig' %}

{% block head deferred %}
<meta charset="utf-8" />
<title>{% if page.title %}{{ page.title|e('html') }} | {% endif %}{{ site.title|e('html') }}</title>

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% include 'partials/metadata.html.twig' %}

{# get favicon from theme config if it exists #}
{% set favicon = theme_var('favicon') %}
{% if favicon %}
{% set favicon_file = (favicon|first).name %}
{% set file_type = favicon_file|split('.')|last %}
<link rel="icon" type="image/{{ file_type }}" href="{{ url('theme://images/' ~ favicon_file) }}" />
{% else %}
<link rel="icon" type="image/png" href="{{ url('theme://images/favicon.png') }}" />
{% endif %}

<link rel="canonical" href="{{ page.url(true, true) }}" />
{% endblock head %}

{% block stylesheets %}
{% do assets.addCss('theme://css-compiled/spectre'~compress) %}
{% if theme_var('spectre.exp') %}{% do assets.addCss('theme://css-compiled/spectre-exp'~compress) %}{% endif %}
Expand Down

0 comments on commit cf14671

Please sign in to comment.