From 07c45c228b7fc1a55360e209ee839f9538227cc0 Mon Sep 17 00:00:00 2001 From: goodroot <9484709+goodroot@users.noreply.github.com> Date: Fri, 13 Dec 2024 08:48:04 -0800 Subject: [PATCH] try transformItems function --- docusaurus.config.js | 7 ++++++- src/theme/SearchBar.tsx | 45 ----------------------------------------- 2 files changed, 6 insertions(+), 46 deletions(-) delete mode 100644 src/theme/SearchBar.tsx diff --git a/docusaurus.config.js b/docusaurus.config.js index 2ced3fc3..7d9ddd16 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -128,10 +128,15 @@ const config = { appId: process.env.ALGOLIA_APP_ID, apiKey: process.env.ALGOLIA_API_KEY, indexName: "questdb", - // Disable /search page searchPagePath: false, contextualSearch: false, externalUrlRegex: 'questdb\\.io', + transformItems: (items) => { + return items.map((item) => ({ + ...item, + isExternal: false, + })) + }, }, } : {}), diff --git a/src/theme/SearchBar.tsx b/src/theme/SearchBar.tsx deleted file mode 100644 index 374fc893..00000000 --- a/src/theme/SearchBar.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { useEffect } from 'react'; -import SearchBar from '@theme-original/SearchBar'; -import type SearchBarType from '@theme/SearchBar'; -import type {WrapperProps} from '@docusaurus/types'; - -type Props = WrapperProps; - -// Not anyones favourite, but this prevents -// search results from being opened in a new tab - -export default function SearchBarWrapper(props: Props): JSX.Element { - useEffect(() => { - const handleSearchResults = () => { - const searchResults = document.querySelector('.DocSearch-content'); - if (searchResults) { - const links = searchResults.getElementsByTagName('a'); - Array.from(links).forEach(link => { - link.setAttribute('target', '_blank'); - link.setAttribute('rel', 'noopener noreferrer'); - }); - } - }; - - const observer = new MutationObserver((mutations) => { - mutations.forEach((mutation) => { - if (mutation.addedNodes.length) { - handleSearchResults(); - } - }); - }); - - observer.observe(document.body, { - childList: true, - subtree: true, - }); - - return () => observer.disconnect(); - }, []); - - return ( - <> - - - ); -}