Skip to content

Commit 6a7ea6c

Browse files
search bar
1 parent 8316e29 commit 6a7ea6c

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/components/AlgoliaSiteSearch/index.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ export default function AlgoliaSiteSearch(): React.ReactElement | null {
9393
const isConfigured = Boolean(applicationId && apiKey && indexName);
9494

9595
useEffect(() => {
96+
ensureSiteSearchStylesheet();
97+
9698
if (!isConfigured) {
9799
return;
98100
}
99101

100102
let cancelled = false;
101103

102-
ensureSiteSearchStylesheet();
103104
loadSiteSearchScript()
104105
.then(() => {
105106
if (cancelled || !window.SiteSearch?.init) {
@@ -139,7 +140,36 @@ export default function AlgoliaSiteSearch(): React.ReactElement | null {
139140
}, [apiKey, applicationId, indexName, isConfigured]);
140141

141142
if (!isConfigured) {
142-
return null;
143+
return (
144+
<div className="navbar__item algolia-sitesearch-navbar">
145+
<button
146+
className="sitesearch-button"
147+
style={{ opacity: 0.6, cursor: "not-allowed" }}
148+
title="Search (Algolia SiteSearch credentials not configured)"
149+
>
150+
<span className="search-icon">
151+
<svg
152+
width="18"
153+
height="18"
154+
viewBox="0 0 24 24"
155+
fill="none"
156+
stroke="currentColor"
157+
strokeWidth="2"
158+
strokeLinecap="round"
159+
strokeLinejoin="round"
160+
>
161+
<circle cx="11" cy="11" r="8"></circle>
162+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
163+
</svg>
164+
</span>
165+
<span className="button-text">Search...</span>
166+
<span className="keyboard-shortcut">
167+
<span>Ctrl</span>
168+
<span>K</span>
169+
</span>
170+
</button>
171+
</div>
172+
);
143173
}
144174

145175
return (

src/css/custom.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,6 @@ body {
763763
}
764764

765765
.navbar__items--right>.navbar__item:not(:has(#clerk-auth-navbar)),
766-
.navbar__items--right .algolia-sitesearch-navbar,
767766
.navbar__items--right .colorModeToggle {
768767
display: none !important;
769768
}
@@ -2866,7 +2865,6 @@ html[data-theme="dark"] .blog-post-page article header h2[itemprop="headline"] {
28662865

28672866
.navbar__inner>.navbar__items>.navbar__item:not(.navbar__toggle),
28682867
.navbar__items--right>.navbar__item,
2869-
.navbar__items--right .algolia-sitesearch-navbar,
28702868
.navbar__items--right .colorModeToggle {
28712869
display: none !important;
28722870
}

0 commit comments

Comments
 (0)