From cf14671114e0c467834373860ec1930fb9971172 Mon Sep 17 00:00:00 2001 From: Nicholas Krebs Date: Tue, 20 Aug 2024 12:22:53 +0200 Subject: [PATCH] add theme option to select a custom favicon --- languages/de.yaml | 3 +++ languages/en.yaml | 3 +++ templates/partials/base.html.twig | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/languages/de.yaml b/languages/de.yaml index 284d27e..8197142 100644 --- a/languages/de.yaml +++ b/languages/de.yaml @@ -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` diff --git a/languages/en.yaml b/languages/en.yaml index 07ccb18..020e293 100644 --- a/languages/en.yaml +++ b/languages/en.yaml @@ -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` diff --git a/templates/partials/base.html.twig b/templates/partials/base.html.twig index 91f6500..04eda22 100644 --- a/templates/partials/base.html.twig +++ b/templates/partials/base.html.twig @@ -1,5 +1,26 @@ {% extends '@quark-open-publishing/partials/base.html.twig' %} +{% block head deferred %} + +{% if page.title %}{{ page.title|e('html') }} | {% endif %}{{ site.title|e('html') }} + + + +{% 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 %} + +{% else %} + +{% endif %} + + +{% 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 %}