Skip to content

Commit 0b8712c

Browse files
committed
Add GitHub Actions workflow for deploying Next.js site
1 parent 55d4f18 commit 0b8712c

File tree

8 files changed

+148
-10
lines changed

8 files changed

+148
-10
lines changed

.github/workflows/deploy.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Sample workflow for building and deploying a Next.js site to GitHub Pages
2+
#
3+
# To get started with Next.js see: https://nextjs.org/docs/getting-started
4+
#
5+
name: Deploy Next.js site to Pages
6+
7+
on:
8+
# Runs on pushes targeting the default branch
9+
push:
10+
branches: ["main"]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
23+
concurrency:
24+
group: "pages"
25+
cancel-in-progress: false
26+
27+
jobs:
28+
# Build job
29+
build:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Node
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: "lts/*"
39+
cache: "bun"
40+
41+
- name: Setup Pages
42+
uses: actions/configure-pages@v4
43+
44+
- name: Restore cache
45+
uses: actions/cache@v4
46+
with:
47+
path: |
48+
.next/cache
49+
# Generate a new cache whenever packages or source files change.
50+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
51+
# If source files changed but packages didn't, rebuild from a prior cache.
52+
restore-keys: |
53+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
54+
55+
- name: Install dependencies
56+
run: bun install
57+
58+
- name: Build with Next.js
59+
run: bun next build
60+
61+
- name: Upload artifact
62+
uses: actions/upload-pages-artifact@v3
63+
with:
64+
path: ./out
65+
66+
# Deployment job
67+
deploy:
68+
environment:
69+
name: github-pages
70+
url: ${{ steps.deployment.outputs.page_url }}
71+
runs-on: ubuntu-latest
72+
needs: build
73+
steps:
74+
- name: Deploy to GitHub Pages
75+
id: deployment
76+
uses: actions/deploy-pages@v4

app/api/search/route.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { source } from '@/lib/source';
22
import { createFromSource } from 'fumadocs-core/search/server';
33

4-
export const { GET } = createFromSource(source, {
5-
// https://docs.orama.com/docs/orama-js/supported-languages
6-
language: 'english',
7-
});
4+
// statically cached
5+
export const revalidate = false;
6+
export const { staticGET: GET } = createFromSource(source);

app/layout.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import '@/app/global.css';
22
import { RootProvider } from 'fumadocs-ui/provider/next';
33
import { Inter } from 'next/font/google';
4+
import SearchDialog from '@/components/search';
45

56
const inter = Inter({
67
subsets: ['latin'],
@@ -10,7 +11,11 @@ export default function Layout({ children }: LayoutProps<'/'>) {
1011
return (
1112
<html lang="en" className={inter.className} suppressHydrationWarning>
1213
<body className="flex flex-col min-h-screen">
13-
<RootProvider>{children}</RootProvider>
14+
<RootProvider
15+
search={{
16+
SearchDialog,
17+
}}
18+
>{children}</RootProvider>
1419
</body>
1520
</html>
1621
);

bun.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"": {
55
"name": "riven-wiki",
66
"dependencies": {
7+
"@orama/orama": "^3.1.14",
78
"fumadocs-core": "15.8.3",
89
"fumadocs-mdx": "12.0.2",
910
"fumadocs-ui": "15.8.3",

components/search.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use client';
2+
import {
3+
SearchDialog,
4+
SearchDialogClose,
5+
SearchDialogContent,
6+
SearchDialogHeader,
7+
SearchDialogIcon,
8+
SearchDialogInput,
9+
SearchDialogList,
10+
SearchDialogOverlay,
11+
type SharedProps,
12+
} from 'fumadocs-ui/components/dialog/search';
13+
import { useDocsSearch } from 'fumadocs-core/search/client';
14+
import { create } from '@orama/orama';
15+
import { useI18n } from 'fumadocs-ui/contexts/i18n';
16+
17+
function initOrama() {
18+
return create({
19+
schema: { _: 'string' },
20+
// https://docs.orama.com/docs/orama-js/supported-languages
21+
language: 'english',
22+
});
23+
}
24+
25+
export default function DefaultSearchDialog(props: SharedProps) {
26+
const { locale } = useI18n(); // (optional) for i18n
27+
const { search, setSearch, query } = useDocsSearch({
28+
type: 'static',
29+
initOrama,
30+
locale,
31+
});
32+
33+
return (
34+
<SearchDialog
35+
search={search}
36+
onSearchChange={setSearch}
37+
isLoading={query.isLoading}
38+
{...props}
39+
>
40+
<SearchDialogOverlay />
41+
<SearchDialogContent>
42+
<SearchDialogHeader>
43+
<SearchDialogIcon />
44+
<SearchDialogInput />
45+
<SearchDialogClose />
46+
</SearchDialogHeader>
47+
<SearchDialogList items={query.data !== 'empty' ? query.data : null} />
48+
</SearchDialogContent>
49+
</SearchDialog>
50+
);
51+
}

next.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ const withMDX = createMDX();
55
/** @type {import('next').NextConfig} */
66
const config = {
77
reactStrictMode: true,
8+
output: 'export',
9+
// basePath: '/wiki',
10+
images: {
11+
unoptimized: true,
12+
}
813
};
914

1015
export default withMDX(config);

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
"lint": "eslint"
1111
},
1212
"dependencies": {
13+
"@orama/orama": "^3.1.14",
14+
"fumadocs-core": "15.8.3",
15+
"fumadocs-mdx": "12.0.2",
16+
"fumadocs-ui": "15.8.3",
17+
"lucide-react": "^0.544.0",
1318
"next": "15.5.4",
1419
"react": "^19.2.0",
15-
"react-dom": "^19.2.0",
16-
"lucide-react": "^0.544.0",
17-
"fumadocs-ui": "15.8.3",
18-
"fumadocs-core": "15.8.3",
19-
"fumadocs-mdx": "12.0.2"
20+
"react-dom": "^19.2.0"
2021
},
2122
"devDependencies": {
2223
"@types/node": "24.6.2",

public/.nojekyll

Whitespace-only changes.

0 commit comments

Comments
 (0)