Skip to content

Commit d71673f

Browse files
committed
feat: algolia
1 parent 30c26b6 commit d71673f

13 files changed

+547
-81
lines changed

Diff for: .env

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
NEXT_PUBLIC_PROXY_URL=http://localhost:8787
2+
NEXT_PUBLIC_ALGOLIA_APP_ID=L0EAOEJCCQ
3+
NEXT_PUBLIC_ALGOLIA_INDEX=docs_index
4+
NEXT_PUBLIC_ALGOLIA_API_KEY=30fe2c1027197e7f8df72f43f2c655ea
5+
ALGOLIA_API_KEY=9257faef9304ccf071a38ef2bb5db567

Diff for: .github/workflows/deploy.yml

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ jobs:
5959
- name: Build with Next.js
6060
env:
6161
NEXT_PUBLIC_PROXY_URL: "https://classcharts-proxy.veloi.workers.dev"
62+
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}
63+
NEXT_PUBLIC_ALGOLIA_INDEX: ${{ secrets.NEXT_PUBLIC_ALGOLIA_INDEX }}
64+
NEXT_PUBLIC_ALGOLIA_API_KEY: ${{ secrets.NEXT_PUBLIC_ALGOLIA_API_KEY }}
65+
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
66+
6267
run: pnpm build
6368

6469
- name: Upload artifact

Diff for: app/api/search/route.ts

-12
This file was deleted.

Diff for: app/layout.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
"use client";
2-
3-
import { useServiceWorker } from "@/hooks/use-service-worker";
41
import "./global.css";
5-
import { RootProvider } from "fumadocs-ui/provider";
62
import { Inter } from "next/font/google";
73
import type { ReactNode } from "react";
4+
import { Provider } from "./provider";
85

96
const inter = Inter({
107
subsets: ["latin"],
118
});
129

1310
export default function Layout({ children }: { children: ReactNode }) {
14-
useServiceWorker();
15-
1611
return (
1712
<html lang="en" className={inter.className} suppressHydrationWarning>
1813
<body>
19-
<RootProvider>{children}</RootProvider>
14+
<Provider>{children}</Provider>
2015
</body>
2116
</html>
2217
);

Diff for: app/provider.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use client";
2+
import { useServiceWorker } from "@/hooks/use-service-worker";
3+
import { RootProvider } from "fumadocs-ui/provider";
4+
import dynamic from "next/dynamic";
5+
import type { ReactNode } from "react";
6+
7+
const SearchDialog = dynamic(() => import("@/components/search"));
8+
9+
export function Provider({ children }: { children: ReactNode }) {
10+
useServiceWorker();
11+
12+
return (
13+
<RootProvider
14+
search={{
15+
SearchDialog,
16+
}}
17+
>
18+
{children}
19+
</RootProvider>
20+
);
21+
}

Diff for: components/search.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use client";
2+
3+
import algo from "algoliasearch/lite";
4+
import type { SharedProps } from "fumadocs-ui/components/dialog/search";
5+
import SearchDialog from "fumadocs-ui/components/dialog/search-algolia";
6+
7+
const appId = process.env.NEXT_PUBLIC_ALGOLIA_APP_ID;
8+
const apiKey = process.env.NEXT_PUBLIC_ALGOLIA_API_KEY;
9+
const indexName = process.env.NEXT_PUBLIC_ALGOLIA_INDEX;
10+
11+
if (!appId || !apiKey || !indexName) throw new Error("Algolia credentials");
12+
13+
const client = algo(appId, apiKey);
14+
15+
const index = client.initIndex(indexName);
16+
17+
export default function CustomSearchDialog(
18+
props: SharedProps,
19+
): React.ReactElement {
20+
return <SearchDialog index={index} {...props} showAlgolia />;
21+
}

Diff for: package.json

+38-32
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
{
2-
"name": "api-docs",
3-
"version": "0.0.0",
4-
"private": true,
5-
"scripts": {
6-
"build": "next build",
7-
"dev": "next dev",
8-
"start": "next start",
9-
"postinstall": "fumadocs-mdx"
10-
},
11-
"dependencies": {
12-
"@icons-pack/react-simple-icons": "^10.0.0",
13-
"fumadocs-core": "13.4.10",
14-
"fumadocs-mdx": "10.0.2",
15-
"fumadocs-openapi": "^5.4.14",
16-
"fumadocs-ui": "13.4.10",
17-
"lucide-react": "^0.447.0",
18-
"next": "^14.2.8",
19-
"react": "^18.3.1",
20-
"react-dom": "^18.3.1",
21-
"tailwind-merge": "^2.5.3"
22-
},
23-
"devDependencies": {
24-
"@types/mdx": "^2.0.13",
25-
"@types/node": "22.5.4",
26-
"@types/react": "^18.3.5",
27-
"@types/react-dom": "^18.3.0",
28-
"autoprefixer": "^10.4.20",
29-
"postcss": "^8.4.45",
30-
"tailwindcss": "^3.4.10",
31-
"typescript": "^5.5.4"
32-
}
33-
}
2+
"name": "api-docs",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"generate": "tsx scripts/generate-docs.mts",
7+
"postbuild": "tsx scripts/post-build.mts",
8+
"build": "next build",
9+
"dev": "next dev",
10+
"start": "next start",
11+
"postinstall": "fumadocs-mdx"
12+
},
13+
"dependencies": {
14+
"@icons-pack/react-simple-icons": "^10.0.0",
15+
"@next/env": "^14.2.14",
16+
"algoliasearch": "^4.24.0",
17+
"fumadocs-core": "13.4.10",
18+
"fumadocs-mdx": "10.0.2",
19+
"fumadocs-openapi": "^5.4.14",
20+
"fumadocs-ui": "13.4.10",
21+
"lucide-react": "^0.447.0",
22+
"next": "^14.2.8",
23+
"react": "^18.3.1",
24+
"react-dom": "^18.3.1",
25+
"tailwind-merge": "^2.5.3"
26+
},
27+
"devDependencies": {
28+
"@types/mdx": "^2.0.13",
29+
"@types/node": "22.5.4",
30+
"@types/react": "^18.3.5",
31+
"@types/react-dom": "^18.3.0",
32+
"autoprefixer": "^10.4.20",
33+
"postcss": "^8.4.45",
34+
"rimraf": "^6.0.1",
35+
"tailwindcss": "^3.4.10",
36+
"tsx": "^4.19.1",
37+
"typescript": "^5.5.4"
38+
}
39+
}

0 commit comments

Comments
 (0)