Skip to content

Commit 64a3cd2

Browse files
committed
docs: add algolia docsearch
1 parent f90d0d6 commit 64a3cd2

File tree

5 files changed

+285
-34
lines changed

5 files changed

+285
-34
lines changed

docs/package-lock.json

+237
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@astrojs/tailwind": "^4.0.0",
15+
"@docsearch/js": "^3.5.1",
1516
"@tailwindcss/typography": "^0.5.9",
1617
"astro": "^2.10.7",
1718
"tailwindcss": "^3.3.3"

docs/src/components/Search.astro

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<button
2+
id="docsearch"
3+
class="p-2 mr-2 hidden md:flex justify-between items-center bg-gray3 bg-opacity-10 hover:bg-opacity-20 border border-gray4 hover:border-orange-500 transition-all"
4+
>
5+
</button>
6+
7+
<script>
8+
import docsearch from "@docsearch/js";
9+
import "@docsearch/css";
10+
console.log("docsearch");
11+
12+
docsearch({
13+
container: "#docsearch",
14+
appId: "FPK5SXN3GJ",
15+
indexName: "sveltefire-fireship",
16+
apiKey: "15bb134d41bb45724983679a6126b5f8",
17+
});
18+
</script>

docs/src/components/TopNav.astro

+6-34
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
import Search from './Search.astro'
3+
---
4+
5+
16
<nav
27
transition:persist
38
class="flex justify-between mx-auto h-20 px-6 w-full bg-gray1 dark:bg-gray7 z-50 relative"
@@ -31,38 +36,7 @@
3136
</li>
3237

3338
<li class="mx-4">
34-
<button
35-
class="p-2 mr-2 hidden md:flex justify-between items-center bg-gray3 bg-opacity-10 hover:bg-opacity-20 border border-gray4 hover:border-orange-500 transition-all"
36-
>
37-
<span class="text-gray4 dark:text-gray2 w-4 mx-2">
38-
<svg
39-
aria-hidden="true"
40-
focusable="false"
41-
data-prefix="fad"
42-
data-icon="search"
43-
role="img"
44-
xmlns="http://www.w3.org/2000/svg"
45-
viewBox="0 0 512 512"
46-
class="svg-inline--fa fk-search fk-w-16 fk-9x"
47-
>
48-
<g class="fk-group"
49-
><path
50-
fill="currentColor"
51-
d="M208 80a128 128 0 1 1-90.51 37.49A127.15 127.15 0 0 1 208 80m0-80C93.12 0 0 93.12 0 208s93.12 208 208 208 208-93.12 208-208S322.88 0 208 0z"
52-
class="fk-secondary"></path><path
53-
fill="currentColor"
54-
d="M504.9 476.7L476.6 505a23.9 23.9 0 0 1-33.9 0L343 405.3a24 24 0 0 1-7-17V372l36-36h16.3a24 24 0 0 1 17 7l99.7 99.7a24.11 24.11 0 0 1-.1 34z"
55-
class="fk-primary"
56-
>
57-
</path></g
58-
></svg
59-
>
60-
</span>
61-
<span class="mr-12 font-code">search</span>
62-
<span class="mx-2 text-xs border border-gray4 rounded-md p-1 px-2"
63-
>/</span
64-
>
65-
</button>
39+
<Search />
6640
<button class="flex md:hidden">
6741
<span class="text-gray2 w-6 mx-2"></span>
6842
</button>
@@ -112,5 +86,3 @@
11286
sidebar.classList.toggle("hidden");
11387
};
11488
</script>
115-
116-
<style></style>

docs/src/layouts/MainLayout.astro

+23
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Footer from "../components/Footer.astro";
1818

1919
<title>SvelteFire Documentation</title>
2020
<script async defer src="https://buttons.github.io/buttons.js"></script>
21+
<link rel="preconnect" href="https://FPK5SXN3GJ-dsn.algolia.net" crossorigin />
2122
<ViewTransitions />
2223
</head>
2324
<body class="dark:bg-gray6 dark:text-white transition-colors duration-500">
@@ -53,3 +54,25 @@ import Footer from "../components/Footer.astro";
5354
</script>
5455
</body>
5556
</html>
57+
58+
59+
<style is:global>
60+
61+
.DocSearch-Button {
62+
@apply flex items-center justify-center px-0;
63+
}
64+
65+
.DocSearch-Button:hover, .DocSearch-Button:focus {
66+
@apply shadow-none bg-transparent text-gray4;
67+
}
68+
69+
70+
.DocSearch-Search-Icon path {
71+
@apply stroke-gray4;
72+
}
73+
74+
.DocSearch-Button-Placeholder {
75+
@apply font-code lowercase ml-2;
76+
}
77+
78+
</style>

0 commit comments

Comments
 (0)