Skip to content

Commit 7f55d5d

Browse files
authored
Merge pull request #4 from classchartsapi/feat/fumadocs
Feat/fumadocs
2 parents f3a6561 + 729170a commit 7f55d5d

File tree

89 files changed

+3613
-6128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3613
-6128
lines changed

Diff for: .env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NEXT_PUBLIC_PROXY_URL=http://localhost:8787

Diff for: .github/workflows/deploy.yml

+68-15
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,91 @@
1-
name: Deploy to GitHub Pages
1+
name: Deploy Next.js site to Pages
22

33
on:
4-
# Trigger the workflow every time you push to the `main` branch
5-
# Using a different branch name? Replace `main` with your branch’s name
4+
# Runs on pushes targeting the default branch
65
push:
7-
branches: [main]
8-
# Allows you to run this workflow manually from the Actions tab on GitHub.
6+
branches: ["main"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
99
workflow_dispatch:
1010

11-
# Allow this job to clone the repo and create a page deployment
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1212
permissions:
1313
contents: read
1414
pages: write
1515
id-token: write
1616

17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
1723
jobs:
24+
# Build job
1825
build:
1926
runs-on: ubuntu-latest
2027
steps:
21-
- name: Checkout your repository using git
28+
- name: Checkout
2229
uses: actions/checkout@v4
23-
- name: Install, build, and upload your site output
24-
uses: withastro/action@v2
25-
# with:
26-
# path: . # The root location of your Astro project inside the repository. (optional)
27-
# node-version: 20 # The specific version of Node that should be used to build your site. Defaults to 18. (optional)
28-
# package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
2930

31+
- name: Detect package manager
32+
id: detect-package-manager
33+
run: |
34+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
35+
echo "manager=yarn" >> $GITHUB_OUTPUT
36+
echo "command=install" >> $GITHUB_OUTPUT
37+
echo "runner=yarn" >> $GITHUB_OUTPUT
38+
exit 0
39+
elif [ -f "${{ github.workspace }}/package.json" ]; then
40+
echo "manager=npm" >> $GITHUB_OUTPUT
41+
echo "command=ci" >> $GITHUB_OUTPUT
42+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
43+
exit 0
44+
else
45+
echo "Unable to determine package manager"
46+
exit 1
47+
fi
48+
49+
- name: Setup Node
50+
uses: actions/setup-node@v4
51+
with:
52+
node-version: "lts/*"
53+
cache: ${{ steps.detect-package-manager.outputs.manager }}
54+
55+
- name: Setup Pages
56+
uses: actions/configure-pages@v4
57+
58+
- name: Restore cache
59+
uses: actions/cache@v4
60+
with:
61+
path: |
62+
.next/cache
63+
# Generate a new cache whenever packages or source files change.
64+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
65+
# If source files changed but packages didn't, rebuild from a prior cache.
66+
restore-keys: |
67+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
68+
69+
- name: Install dependencies
70+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
71+
72+
- name: Build with Next.js
73+
env:
74+
NEXT_PUBLIC_PROXY_URL: "https://classcharts-proxy.veloi.workers.dev"
75+
run: ${{ steps.detect-package-manager.outputs.runner }} next build
76+
77+
- name: Upload artifact
78+
uses: actions/upload-pages-artifact@v3
79+
with:
80+
path: ./out
81+
82+
# Deployment job
3083
deploy:
31-
needs: build
32-
runs-on: ubuntu-latest
3384
environment:
3485
name: github-pages
3586
url: ${{ steps.deployment.outputs.page_url }}
87+
runs-on: ubuntu-latest
88+
needs: build
3689
steps:
3790
- name: Deploy to GitHub Pages
3891
id: deployment

Diff for: .gitignore

+22-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
# build output
2-
dist/
3-
# generated types
4-
.astro/
1+
# deps
2+
/node_modules
53

6-
# dependencies
7-
node_modules/
4+
# generated content
5+
.contentlayer
6+
.content-collections
7+
.source
88

9-
# logs
9+
# test & build
10+
/coverage
11+
/.next/
12+
/out/
13+
/build
14+
*.tsbuildinfo
15+
16+
# misc
17+
.DS_Store
18+
*.pem
19+
/.pnp
20+
.pnp.js
1021
npm-debug.log*
1122
yarn-debug.log*
1223
yarn-error.log*
13-
pnpm-debug.log*
14-
1524

16-
# environment variables
17-
.env
18-
.env.production
19-
20-
# macOS-specific files
21-
.DS_Store
25+
# others
26+
.env*.local
27+
.vercel
28+
next-env.d.ts

Diff for: README.md

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
# ClassCharts API Docs
1+
# api-docs
22

3-
Unofficial API documentation for ClassCharts.
3+
This is a Next.js application generated with
4+
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).
45

6+
Run development server:
57

6-
[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)
8+
```bash
9+
npm run dev
10+
# or
11+
pnpm dev
12+
# or
13+
yarn dev
14+
```
715

16+
Open http://localhost:3000 with your browser to see the result.
817

9-
## Development Commands
18+
## Learn More
1019

11-
All commands are run from the root of the project, from a terminal:
20+
To learn more about Next.js and Fumadocs, take a look at the following
21+
resources:
1222

13-
| Command | Action |
14-
| :------------------------- | :----------------------------------------------- |
15-
| `pnpm install` | Installs dependencies |
16-
| `pnpm run dev` | Starts local dev server at `localhost:4321` |
17-
| `pnpm run build` | Build your production site to `./dist/` |
18-
| `pnpm run preview` | Preview your build locally, before deploying |
19-
| `pnpm run astro ...` | Run CLI commands like `astro add`, `astro check` |
20-
| `pnpm run astro -- --help` | Get help using the Astro CLI |
23+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
24+
features and API.
25+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
26+
- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs

Diff for: app/(docs)/[[...slug]]/page.tsx

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { openapi, source } from "@/app/source";
2+
import type { Metadata } from "next";
3+
import {
4+
DocsPage,
5+
DocsBody,
6+
DocsDescription,
7+
DocsTitle,
8+
} from "fumadocs-ui/page";
9+
import { notFound } from "next/navigation";
10+
import defaultMdxComponents from "fumadocs-ui/mdx";
11+
12+
export default async function Page({
13+
params,
14+
}: {
15+
params: { slug?: string[] };
16+
}) {
17+
const page = source.getPage(params.slug);
18+
if (!page) notFound();
19+
20+
const MDX = page.data.body;
21+
22+
return (
23+
<DocsPage toc={page.data.toc} full={page.data.full}>
24+
<DocsTitle>{page.data.title}</DocsTitle>
25+
<DocsDescription>{page.data.description}</DocsDescription>
26+
<DocsBody>
27+
<MDX
28+
components={{ ...defaultMdxComponents, APIPage: openapi.APIPage }}
29+
/>
30+
</DocsBody>
31+
</DocsPage>
32+
);
33+
}
34+
35+
export async function generateStaticParams() {
36+
return source.generateParams();
37+
}
38+
39+
export function generateMetadata({ params }: { params: { slug?: string[] } }) {
40+
const page = source.getPage(params.slug);
41+
if (!page) notFound();
42+
43+
return {
44+
title: page.data.title,
45+
description: page.data.description,
46+
} satisfies Metadata;
47+
}

Diff for: app/(docs)/layout.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { DocsLayout } from 'fumadocs-ui/layout';
2+
import type { ReactNode } from 'react';
3+
import { baseOptions } from '../layout.config';
4+
import { source } from '@/app/source';
5+
6+
export default function Layout({ children }: { children: ReactNode }) {
7+
return (
8+
<DocsLayout tree={source.pageTree} {...baseOptions}>
9+
{children}
10+
</DocsLayout>
11+
);
12+
}

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

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { source } from '@/app/source';
2+
import { createSearchAPI } from 'fumadocs-core/search/server';
3+
4+
export const { GET } = createSearchAPI('advanced', {
5+
indexes: source.getPages().map((page) => ({
6+
title: page.data.title,
7+
description: page.data.description,
8+
structuredData: page.data.structuredData,
9+
id: page.url,
10+
url: page.url,
11+
})),
12+
});

Diff for: app/global.css

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
:root {
6+
--fd-sidebar-width: 375px;
7+
--primary: 221.2 83.2% 53.3%;
8+
}
9+
10+
.dark {
11+
--primary: 213.1 93.9% 67.8%;
12+
}

Diff for: app/layout.config.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { type HomeLayoutProps } from "fumadocs-ui/home-layout";
2+
3+
/**
4+
* Shared layout configurations
5+
*
6+
* you can configure layouts individually from:
7+
* Home Layout: app/(home)/layout.tsx
8+
* Docs Layout: app/docs/layout.tsx
9+
*/
10+
export const baseOptions: HomeLayoutProps = {
11+
nav: {
12+
title: <span className="text-lg md:ml-2">ClassCharts API Docs</span>,
13+
transparentMode: "top",
14+
},
15+
};

Diff for: app/layout.tsx

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use client";
2+
3+
import { useServiceWorker } from "@/hooks/use-service-worker";
4+
import "./global.css";
5+
import { RootProvider } from "fumadocs-ui/provider";
6+
import { Inter } from "next/font/google";
7+
import type { ReactNode } from "react";
8+
9+
const inter = Inter({
10+
subsets: ["latin"],
11+
});
12+
13+
export default function Layout({ children }: { children: ReactNode }) {
14+
useServiceWorker();
15+
16+
return (
17+
<html lang="en" className={inter.className} suppressHydrationWarning>
18+
<body>
19+
<RootProvider>{children}</RootProvider>
20+
</body>
21+
</html>
22+
);
23+
}

Diff for: app/source.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { docs, meta } from "@/.source";
2+
import { createMDXSource } from "fumadocs-mdx";
3+
import { loader } from "fumadocs-core/source";
4+
import { createOpenAPI, attachFile } from "fumadocs-openapi/server";
5+
import { icons } from "lucide-react";
6+
import { createElement } from "react";
7+
import { IconContainer } from "@/components/ui/icon";
8+
9+
export const source = loader({
10+
baseUrl: "/",
11+
source: createMDXSource(docs, meta),
12+
pageTree: {
13+
attachFile,
14+
},
15+
icon(icon) {
16+
if (!icon) {
17+
return;
18+
}
19+
20+
if (icon in icons)
21+
return createElement(IconContainer, {
22+
icon: icons[icon as keyof typeof icons],
23+
});
24+
},
25+
});
26+
27+
export const openapi = createOpenAPI({});

0 commit comments

Comments
 (0)