Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 11.5.2
run_install: false

- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"

- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline

- name: Lint
run: pnpm run lint
- name: Type Check
run: pnpm run types:check
- name: Build
run: pnpm run build
28 changes: 0 additions & 28 deletions .github/workflows/linter.yml

This file was deleted.

60 changes: 0 additions & 60 deletions .github/workflows/publish.yml

This file was deleted.

33 changes: 21 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# Dependencies
# deps
/node_modules

# Production
/build
# generated content
.source

# Generated files
.docusaurus
.cache-loader
# test & build
/coverage
/.next/
/out/
/build
*.tsbuildinfo

# Misc
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

*.pem
/.pnp
.pnp.js
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# others
.env*.local
.vercel
next-env.d.ts

# temp files
*.temp
70 changes: 57 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,77 @@
# Cocos Docs

This repo collects the collaborative work on Cocos AI documentation. Official documentation is hosted at [Cocos Docs page](https://docs.cocos.ultraviolet.rs).
This is the source code for the Cocos AI documentation site, built with [Next.js](https://nextjs.org/) and [Fumadocs](https://fumadocs.dev/).

Documentation is auto-generated from Markdown files in this repo.
The site is configured to live under:

### Installation
```txt
https://www.ultraviolet.rs/docs/cocos-ai
```

## Getting Started

### Prerequisites

Doc repo can be fetched from GitHub:
- [Node.js](https://nodejs.org/) (v22 or newer)
- [pnpm](https://pnpm.io/) (v11 or newer)

### Installation

```bash
git clone https://github.com/ultravioletrs/cocos-docs.git
pnpm install
```

```
$ yarn
```
### Develop

### Local Development
Run the development server:

```bash
pnpm dev
```
$ yarn start

Open [http://localhost:3000/docs/cocos-ai](http://localhost:3000/docs/cocos-ai) with your browser to see the docs.

### Validate

```bash
pnpm run lint
pnpm run types:check
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
Biome is used for code linting and formatting:

```bash
pnpm run lint:fix
pnpm run format
```

### Build

```bash
pnpm run build
```
$ yarn build

The build exports static assets to `out/`, then nests the export under `out/docs/cocos-ai` so Cloudflare Workers can serve the docs at the configured base path.

## Project Structure

- `app/`: Next.js app router pages and layouts.
- `content/docs/`: Documentation content in Markdown and MDX.
- `lib/`: Utility functions and Fumadocs configuration.
- `public/`: Static assets, Cloudflare `_headers`, `_redirects`, and `robots.txt`.
- `scripts/nest-static-export.mjs`: Moves the static export under `out/docs/cocos-ai`.
- `wrangler.jsonc`: Cloudflare Workers assets deployment config.

## Deploy

The site is exported as static assets and can be deployed to Cloudflare Workers with Wrangler:

```bash
pnpm run deploy
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.
To upload a version without deploying it immediately:

```bash
pnpm run upload
```
55 changes: 55 additions & 0 deletions app/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
DocsBody,
DocsDescription,
DocsPage,
DocsTitle,
} from "fumadocs-ui/layouts/docs/page";
import { createRelativeLink } from "fumadocs-ui/mdx";
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { toSiteUrl } from "@/lib/base-path";
import { createMetadata } from "@/lib/metadata";
import { source } from "@/lib/source";
import { getMDXComponents } from "@/mdx-components";

export default async function Page(props: PageProps<"/[[...slug]]">) {
const params = await props.params;
const page = source.getPage(params.slug);
if (!page) notFound();

const MDX = page.data.body;

return (
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription>{page.data.description}</DocsDescription>
<DocsBody>
<MDX
components={getMDXComponents({
a: createRelativeLink(source, page),
})}
/>
</DocsBody>
</DocsPage>
);
}

export async function generateStaticParams() {
return [{ slug: [] }, ...source.generateParams()];
}

export async function generateMetadata(
props: PageProps<"/[[...slug]]">,
): Promise<Metadata> {
const params = await props.params;
const page = source.getPage(params.slug);
if (!page) notFound();
const canonical = toSiteUrl(page.url);

return createMetadata({
title: page.data.title,
description: page.data.description,
alternates: { canonical },
openGraph: { url: canonical },
});
}
9 changes: 9 additions & 0 deletions app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createFromSource } from "fumadocs-core/search/server";
import { source } from "@/lib/source";

export const revalidate = false;

export const { staticGET: GET } = createFromSource(source, {
// https://docs.orama.com/docs/orama-js/supported-languages
language: "english",
});
Binary file added app/apple-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/favicon.ico
Binary file not shown.
Loading
Loading