From d603fb6571599aaac6d627a8e47840e649aff3d4 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Thu, 24 Aug 2023 15:09:18 +0200 Subject: [PATCH] ux: enable search for non-prod deploys Search results include the hostname by default. This change strips the hostname which makes it possible to search when the site is deployed on other domains, such as netlify and localhost. Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- assets/js/src/search.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/assets/js/src/search.js b/assets/js/src/search.js index 1b3f40c29d..310cc299f1 100644 --- a/assets/js/src/search.js +++ b/assets/js/src/search.js @@ -1,11 +1,17 @@ -import docsearch from '@docsearch/js'; -import * as params from '@params'; // hugo dict +import docsearch from "@docsearch/js"; +import * as params from "@params"; // hugo dict -const { appid, apikey, indexname } = params +const { appid, apikey, indexname } = params; docsearch({ - container: '#docsearch', + container: "#docsearch", appId: appid, apiKey: apikey, indexName: indexname, + transformItems(items) { + return items.map((item) => ({ + ...item, + url: item.url.replace("https://docs.docker.com", ""), + })); + }, });