Browse Source

[enh] add SVG favicon href="favicon.svg" type="image/svg+xml"

Add link::

    <link rel="icon" href="favicon.png" sizes="any">
    <link rel="icon" href="favicon.svg" type="image/svg+xml">

Modern browsers should request::

    INFO  werkzeug   : 127.0.0.1 - - [28/Nov/2021 17:03:07] "GET /static/themes/simple/img/favicon.svg HTTP/1.1" 200 -

[1] https://github.com/audreyfeldroy/favicon-cheat-sheet#svg-file
[2] https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Markus Heiser 3 years ago
parent
commit
944b73511a

+ 9 - 1
searx/static/themes/simple/gruntfile.js

@@ -150,7 +150,15 @@ module.exports = function(grunt) {
           '<%= _templates %>/__common__/searxng-wordmark.min.svg': '<%= _brand %>/searxng-wordmark.svg',
           'img/searxng.svg': '<%= _brand %>/searxng.svg'
         }
-      }
+      },
+      favicon: {
+        options: {
+          svgo: ['--config', 'svg4favicon.svgo.js']
+        },
+        files: {
+          'img/favicon.svg': '<%= _brand %>/searxng-wordmark.svg'
+        }
+      },
     },
     svg2png: {
       favicon: {

+ 16 - 0
searx/static/themes/simple/svg4favicon.svgo.js

@@ -0,0 +1,16 @@
+/**
+ * @license
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ *
+ * svgo config: Optimize SVG for WEB usage
+ */
+
+module.exports = {
+  plugins: [
+    {
+      name: 'preset-default',
+    },
+    // make diff friendly
+    'sortAttrs',
+ ],
+};

+ 2 - 1
searx/templates/simple/base.html

@@ -31,7 +31,8 @@
   {% block head %}
   <link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}"/>
   {% endblock %}
-  <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" />
+  <link rel="icon" href="{{ url_for('static', filename='img/favicon.png') }}" sizes="any">
+  <link rel="icon" href="{{ url_for('static', filename='img/favicon.svg') }}" type="image/svg+xml">
 </head>
 <body class="{{ endpoint }}_endpoint" >
   <main id="main_{{  self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}">