]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Make OpenSearch an output format.
authorXhmikosR <xhmikosr@gmail.com>
Mon, 17 Feb 2020 16:20:24 +0000 (18:20 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 11 Mar 2024 19:05:45 +0000 (21:05 +0200)
Not sure if there's another way to do this...

hugo.yml
site/layouts/_default/list.opensearch.xml [new file with mode: 0644]
site/layouts/partials/header.html
site/static/documentation-search.xml [deleted file]

index 17f8b7b6806e98c9ec39aa6f9e364ccc7c66d574..c3b566d1e8049f455e6a77b62b45eed49d01a01a 100644 (file)
--- a/hugo.yml
+++ b/hugo.yml
@@ -28,6 +28,18 @@ enableRobotsTXT:        true
 metaDataFormat:         "yaml"
 disableKinds:           ["404", "taxonomy", "term", "RSS"]
 
+outputFormats:
+  OpenSearch:
+    baseName:           opensearch
+    isPlainText:        true
+    mediaType:          application/xml
+    notAlternative:     true
+
+outputs:
+  home:
+    - HTML
+    - OpenSearch
+
 publishDir:             "_site"
 
 module:
diff --git a/site/layouts/_default/list.opensearch.xml b/site/layouts/_default/list.opensearch.xml
new file mode 100644 (file)
index 0000000..a64e0da
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
+  <ShortName>{{ .Site.Title }}</ShortName>
+  <Description>Search {{ .Site.Title }} documentation</Description>
+  <Image type="image/x-icon" width="16" height="16">{{ (printf "/docs/%s/assets/img/favicons/favicon.ico" .Site.Params.docs_version) | absURL }}</Image>
+  <Url type="text/html" method="get" template="{{ (printf "/docs/%s/getting-started/introduction/" .Site.Params.docs_version) | absURL }}#search={searchTerms}"/>
+</OpenSearchDescription>
index a7ad916ee8209872240eb171f47a3736b4c5062c..15047233cf689a956205dc38d6902a128efcc035 100644 (file)
 <title>{{ if .IsHome }}{{ .Site.Title | markdownify }} · {{ .Site.Params.subtitle | markdownify }}{{ else }}{{ .Title | markdownify }} · {{ .Site.Title | markdownify }} v{{ .Site.Params.docs_version }}{{ end }}</title>
 
 <link rel="canonical" href="{{ .Permalink }}">
-<link rel="search" href="/documentation-search.xml" type="application/opensearchdescription+xml">
+
+{{ with .OutputFormats.Get "opensearch" -}}
+<link rel="search" href="{{ .Permalink }}" title="{{ $.Site.Title }}" type="application/opensearchdescription+xml">
+{{ end -}}
 
 <link rel="preconnect" href="https://AK7KMZKZHQ-dsn.algolia.net" crossorigin>
 
diff --git a/site/static/documentation-search.xml b/site/static/documentation-search.xml
deleted file mode 100644 (file)
index 9fdd82d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
-  <ShortName>Bootstrap Documentation</ShortName>
-  <Description>Search in the latest Bootstrap documentation</Description>
-  <Image height="16" width="16" type="image/x-icon">https://deploy-preview-29872--twbs-bootstrap.netlify.com/favicon.ico</Image>
-  <Url type="text/html" method="get" template="https://deploy-preview-29872--twbs-bootstrap.netlify.com/docs/4.3/getting-started/introduction/#search={searchTerms}" />
-</OpenSearchDescription>