Skip to content

Commit e708418

Browse files
authored
Merge pull request #9 from phucbm/search-dialog
Search dialog
2 parents e14f5d9 + adf5b18 commit e708418

File tree

14 files changed

+1575
-7
lines changed

14 files changed

+1575
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
This starter template includes the following features:
66

77
- [x] **Nextra 4**
8-
- [x] **Search with Pagefind**
8+
- [x] **Improved Search UI with Pagefind**
99

1010
[**Live Demo →**](https://nextra.phucbm.com)
1111

12-
[![](.github/screenshot.png)](https://nextra.phucbm.com)
12+
![search-dialog](https://github.com/user-attachments/assets/c2993957-542d-4796-8529-141e16fccb43)
1313

1414
## Quick Start
1515

app/globals.css

Lines changed: 218 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,222 @@
22

33
/* Optional: import Nextra theme styles */
44
@import "nextra-theme-docs/style.css";
5+
@import "tw-animate-css";
56

6-
@variant dark (&:where(.dark *));
7+
@custom-variant dark (&:is(.dark *));
8+
9+
@variant dark (&:where(.dark *));
10+
11+
@theme inline {
12+
13+
--radius-sm: calc(var(--radius) - 4px);
14+
15+
--radius-md: calc(var(--radius) - 2px);
16+
17+
--radius-lg: var(--radius);
18+
19+
--radius-xl: calc(var(--radius) + 4px);
20+
21+
--color-background: var(--background);
22+
23+
--color-foreground: var(--foreground);
24+
25+
--color-card: var(--card);
26+
27+
--color-card-foreground: var(--card-foreground);
28+
29+
--color-popover: var(--popover);
30+
31+
--color-popover-foreground: var(--popover-foreground);
32+
33+
--color-primary: var(--primary);
34+
35+
--color-primary-foreground: var(--primary-foreground);
36+
37+
--color-secondary: var(--secondary);
38+
39+
--color-secondary-foreground: var(--secondary-foreground);
40+
41+
--color-muted: var(--muted);
42+
43+
--color-muted-foreground: var(--muted-foreground);
44+
45+
--color-accent: var(--accent);
46+
47+
--color-accent-foreground: var(--accent-foreground);
48+
49+
--color-destructive: var(--destructive);
50+
51+
--color-border: var(--border);
52+
53+
--color-input: var(--input);
54+
55+
--color-ring: var(--ring);
56+
57+
--color-chart-1: var(--chart-1);
58+
59+
--color-chart-2: var(--chart-2);
60+
61+
--color-chart-3: var(--chart-3);
62+
63+
--color-chart-4: var(--chart-4);
64+
65+
--color-chart-5: var(--chart-5);
66+
67+
--color-sidebar: var(--sidebar);
68+
69+
--color-sidebar-foreground: var(--sidebar-foreground);
70+
71+
--color-sidebar-primary: var(--sidebar-primary);
72+
73+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
74+
75+
--color-sidebar-accent: var(--sidebar-accent);
76+
77+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
78+
79+
--color-sidebar-border: var(--sidebar-border);
80+
81+
--color-sidebar-ring: var(--sidebar-ring);
82+
}
83+
84+
:root {
85+
86+
--radius: 0.625rem;
87+
88+
--background: oklch(1 0 0);
89+
90+
--foreground: oklch(0.145 0 0);
91+
92+
--card: oklch(1 0 0);
93+
94+
--card-foreground: oklch(0.145 0 0);
95+
96+
--popover: oklch(1 0 0);
97+
98+
--popover-foreground: oklch(0.145 0 0);
99+
100+
--primary: oklch(0.205 0 0);
101+
102+
--primary-foreground: oklch(0.985 0 0);
103+
104+
--secondary: oklch(0.97 0 0);
105+
106+
--secondary-foreground: oklch(0.205 0 0);
107+
108+
--muted: oklch(0.97 0 0);
109+
110+
--muted-foreground: oklch(0.556 0 0);
111+
112+
--accent: oklch(0.97 0 0);
113+
114+
--accent-foreground: oklch(0.205 0 0);
115+
116+
--destructive: oklch(0.577 0.245 27.325);
117+
118+
--border: oklch(0.922 0 0);
119+
120+
--input: oklch(0.922 0 0);
121+
122+
--ring: oklch(0.708 0 0);
123+
124+
--chart-1: oklch(0.646 0.222 41.116);
125+
126+
--chart-2: oklch(0.6 0.118 184.704);
127+
128+
--chart-3: oklch(0.398 0.07 227.392);
129+
130+
--chart-4: oklch(0.828 0.189 84.429);
131+
132+
--chart-5: oklch(0.769 0.188 70.08);
133+
134+
--sidebar: oklch(0.985 0 0);
135+
136+
--sidebar-foreground: oklch(0.145 0 0);
137+
138+
--sidebar-primary: oklch(0.205 0 0);
139+
140+
--sidebar-primary-foreground: oklch(0.985 0 0);
141+
142+
--sidebar-accent: oklch(0.97 0 0);
143+
144+
--sidebar-accent-foreground: oklch(0.205 0 0);
145+
146+
--sidebar-border: oklch(0.922 0 0);
147+
148+
--sidebar-ring: oklch(0.708 0 0);
149+
}
150+
151+
.dark {
152+
153+
--background: oklch(0.145 0 0);
154+
155+
--foreground: oklch(0.985 0 0);
156+
157+
--card: oklch(0.205 0 0);
158+
159+
--card-foreground: oklch(0.985 0 0);
160+
161+
--popover: oklch(0.205 0 0);
162+
163+
--popover-foreground: oklch(0.985 0 0);
164+
165+
--primary: oklch(0.922 0 0);
166+
167+
--primary-foreground: oklch(0.205 0 0);
168+
169+
--secondary: oklch(0.269 0 0);
170+
171+
--secondary-foreground: oklch(0.985 0 0);
172+
173+
--muted: oklch(0.269 0 0);
174+
175+
--muted-foreground: oklch(0.708 0 0);
176+
177+
--accent: oklch(0.269 0 0);
178+
179+
--accent-foreground: oklch(0.985 0 0);
180+
181+
--destructive: oklch(0.704 0.191 22.216);
182+
183+
--border: oklch(1 0 0 / 10%);
184+
185+
--input: oklch(1 0 0 / 15%);
186+
187+
--ring: oklch(0.556 0 0);
188+
189+
--chart-1: oklch(0.488 0.243 264.376);
190+
191+
--chart-2: oklch(0.696 0.17 162.48);
192+
193+
--chart-3: oklch(0.769 0.188 70.08);
194+
195+
--chart-4: oklch(0.627 0.265 303.9);
196+
197+
--chart-5: oklch(0.645 0.246 16.439);
198+
199+
--sidebar: oklch(0.205 0 0);
200+
201+
--sidebar-foreground: oklch(0.985 0 0);
202+
203+
--sidebar-primary: oklch(0.488 0.243 264.376);
204+
205+
--sidebar-primary-foreground: oklch(0.985 0 0);
206+
207+
--sidebar-accent: oklch(0.269 0 0);
208+
209+
--sidebar-accent-foreground: oklch(0.985 0 0);
210+
211+
--sidebar-border: oklch(1 0 0 / 10%);
212+
213+
--sidebar-ring: oklch(0.556 0 0);
214+
}
215+
216+
@layer base {
217+
* {
218+
@apply border-border outline-ring/50;
219+
}
220+
body {
221+
@apply bg-background text-foreground;
222+
}
223+
}

app/layout.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {Head} from 'nextra/components'
33
import {getPageMap} from 'nextra/page-map'
44
import './globals.css'
55
import {Metadata} from "next";
6+
import {NextraSearchDialog} from "@/components/nextra-search-dialog";
7+
import {getPagesFromPageMap} from "@/lib/getPagesFromPageMap";
68

79
export const metadata: Metadata = {
810
// Define your metadata here
@@ -19,6 +21,18 @@ const navbar = (
1921
const footer = <Footer>MIT {new Date().getFullYear()} © Nextra.</Footer>
2022

2123
export default async function RootLayout({children}) {
24+
const pageMap = await getPageMap();
25+
const pages = await getPagesFromPageMap({
26+
pageMapArray: pageMap,
27+
// modify page data if needed
28+
// filterItem: async (item) => {
29+
// return {
30+
// ...item,
31+
// };
32+
// }
33+
});
34+
35+
2236
return (
2337
<html
2438
// Not required, but good for SEO
@@ -38,9 +52,10 @@ export default async function RootLayout({children}) {
3852
<Layout
3953
// banner={banner}
4054
navbar={navbar}
41-
pageMap={await getPageMap()}
55+
pageMap={pageMap}
4256
docsRepositoryBase="https://github.com/phucbm/nextra-docs-starter/tree/main"
4357
footer={footer}
58+
search={<NextraSearchDialog pages={pages}/>}
4459
// ... Your additional layout options
4560
>
4661
{children}

components.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"iconLibrary": "lucide",
14+
"aliases": {
15+
"components": "@/components",
16+
"utils": "@/lib/utils",
17+
"ui": "@/components/ui",
18+
"lib": "@/lib",
19+
"hooks": "@/hooks"
20+
},
21+
"registries": {}
22+
}

0 commit comments

Comments
 (0)