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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# generated content
.source
AGENTS.md

# test & build
/coverage
Expand Down
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
# synth-docs
# synth-docs

Documentation site for [Synth](https://github.com/absmach/synth), built with Next.js and Fumadocs. It is a single docs tree served at the site root, with the Enterprise Edition pages under `/user-guide/enterprise/`.

## Requirements

- Node.js 22+
- pnpm 10 (`packageManager` in `package.json`)

```bash
pnpm install # also generates the Fumadocs content collections
```

## Development

```bash
pnpm dev # http://localhost:3000
```

Content images resolve from `public/screenshots/` during development. Production rewrites the same markdown to `/docs/synth/screenshots/...`, which the Worker serves from R2 with a static-export fallback.

Search is served by the static index at `/api/search`.

## Build and preview

```bash
pnpm build # production build
pnpm start # serve the export
```

The build runs a Next export and nests it under the deployed base path:

```text
out/docs/synth/ the docs site
```

With `pnpm start`, open `http://localhost:3000/docs/synth/`.

## Deploy

```bash
pnpm deploy # build and deploy the Worker + static assets
pnpm upload # build and upload a new Worker version without deploying
```

Images can be published to R2 without redeploying the site:

```bash
pnpm publish-image ./screenshot.png docs/synth/screenshots/example.png
```

This requires `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ZONE_ID` (see `scripts/publish-image.mjs`). Local credentials can go in `scripts/.env.publish-image`, which is git-ignored.

## Checks

```bash
pnpm lint # Biome
pnpm types:check # Fumadocs collections, Next types, tsc
pnpm build # production build
```
42 changes: 42 additions & 0 deletions app/(docs)/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { DocPageView } from "@/components/doc-page";
import { docMetadata } from "@/lib/doc-metadata";
import { source } from "@/lib/source";

type ParamProps = {
params: Promise<{ slug?: string[] }>;
};

export default async function Page(props: ParamProps) {
const params = await props.params;
const slug = params.slug && params.slug.length > 0 ? params.slug : [];

// The root catch-all has no page of its own; the only fallback is the
// landing page for `/`. Every other unknown slug is a real 404, not a
// silently served Quick Start with a 200.
const page =
source.getPage(slug) ??
(slug.length === 0
? source.getPage(["user-guide", "quick-start"])
: undefined);
if (!page) notFound();

return <DocPageView source={source} page={page} />;
}

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

export async function generateMetadata(props: ParamProps): Promise<Metadata> {
const params = await props.params;
const slug = params.slug ?? [];

const page = source.getPage(slug);
if (!page) {
return { title: "Synth Docs" };
}

return docMetadata(page);
}
11 changes: 11 additions & 0 deletions app/(docs)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ReactNode } from "react";
import { DocsShell } from "@/components/docs-shell";
import { source } from "@/lib/source";

export default function DocsRootLayout({ children }: { children: ReactNode }) {
return (
<DocsShell home="/" tree={source.getPageTree()}>
{children}
</DocsShell>
);
}
120 changes: 0 additions & 120 deletions app/[[...slug]]/page.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions app/[[...slug]]/root-redirect.tsx

This file was deleted.

Binary file added app/favicon.ico
Binary file not shown.
84 changes: 84 additions & 0 deletions app/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 4 additions & 21 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { DocsLayout } from "fumadocs-ui/layouts/docs";
import type { ReactNode } from "react";
import { EditionSwitcher } from "@/components/edition-switcher";
import { Provider } from "@/components/provider";
import { baseOptions } from "@/lib/layout.shared";
import { source } from "@/lib/source";
import "./global.css";
import { baseUrl, createMetadata } from "@/lib/metadata";
import "./global.css";

export const metadata = createMetadata({
title: {
Expand All @@ -18,24 +14,11 @@ export const metadata = createMetadata({
openGraph: { url: `${baseUrl}/` },
});

export default function Layout({ children }: { children: ReactNode }) {
const base = baseOptions();
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
<body className="flex flex-col min-h-screen">
<Provider>
<DocsLayout
{...base}
tree={source.getPageTree()}
links={base.links?.filter((item) => item.type === "icon")}
nav={{ ...base.nav }}
sidebar={{
banner: <EditionSwitcher />,
}}
>
{children}
</DocsLayout>
</Provider>
<body className="flex flex-col min-h-screen" suppressHydrationWarning>
<Provider>{children}</Provider>
</body>
</html>
);
Expand Down
Loading
Loading