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
10 changes: 8 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,14 @@ jobs:
*) echo "::error::Invalid smoke-test target"; exit 1 ;;
esac

curl --fail --silent --show-error "$URL/" >/dev/null
curl --fail --silent --show-error --location "$URL/docs" >/dev/null
root="$(curl --silent --show-error --output /dev/null --write-out '%{http_code} %{redirect_url}' "$URL/")"
test "$root" = "302 $URL/docs/assay"
docs="$(curl --silent --show-error --output /dev/null --write-out '%{http_code} %{redirect_url}' "$URL/docs")"
test "$docs" = "302 $URL/docs/assay"
landing="$(curl --fail --silent --show-error --location --max-redirs 1 --output /dev/null --write-out '%{http_code} %{num_redirects} %{url_effective}' "$URL/")"
test "$landing" = "200 1 $URL/docs/assay"
curl --fail --silent --show-error "$URL/docs/assay" >/dev/null
curl --fail --silent --show-error "$URL/docs/throughline" >/dev/null
curl --fail --silent --show-error "$URL/llms.txt" >/dev/null
curl --fail --silent --show-error "$URL/llms-full.txt" >/dev/null
curl --fail --silent --show-error "$URL/robots.txt" >/dev/null
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Fumadocs owns the documentation navigation. The repository is organized by tool,
```text
content/docs/
├── meta.json # Shared tool order
├── assay/ # Default product
│ ├── meta.json
│ └── index.mdx
├── throughline/
│ ├── meta.json # Throughline navigation
│ ├── index.mdx # Tool overview
Expand All @@ -19,7 +22,7 @@ content/docs/
└── *.mdx
```

- The root `content/docs/meta.json` lists Throughline first and uses Fumadocs' `"..."` entry to include future tools automatically.
- The root `content/docs/meta.json` lists Assay first, then Throughline and uses Fumadocs' `"..."` entry to include future tools automatically.
- Give every tool its own `content/docs/<slug>/` directory with an `index.mdx` and `meta.json`. Set `"root": true` in the tool's metadata so its navigation is separate from other tools. Give it a clear title, a short description, and an explicit `pages` order. Section separators such as `"---Reference---"` group related pages without changing URLs.
- Use stable filenames: Fumadocs derives each public address from its MDX path. Navigation changes must not unnecessarily change existing addresses.
- New tools also need a published product entry in the R2 catalog, with no outbound `url`, before they appear on the public site. Content files alone do not publish a product.
Expand All @@ -37,7 +40,7 @@ The showcase is deliberately limited to a few pages and does not automatically t

The private `0xbuffdev/content` repository owns the product records and publishes them to independent 0xBUFF buckets via its validated content pipeline. Documentation reads `manifest.json` and the referenced `products/manifest.json` through its Worker `CONTENT` R2 binding and validates them with `@0xbuffdev/[email protected]` (imported as `@0xbuff/content-contract`).

Only published product records with **no outbound `url`** and a matching `content/docs/<slug>/index.mdx` are listed. The R2 catalog controls the homepage, documentation routes, sidebar, sitemap, search index and LLM exports. The MDX articles themselves are compiled from this repository and require a documentation deployment to update. Catalog changes appear after the 60-second edge cache expires; no documentation rebuild is needed for catalog changes alone.
Only published product records with **no outbound `url`** and a matching `content/docs/<slug>/index.mdx` are listed. The R2 catalog controls documentation routes, sidebar, sitemap, search index and LLM exports. Both `/` and `/docs` temporarily redirect directly to `/docs/assay` in one hop, only when Assay is published. Missing Assay returns 503 rather than falling back to another tool. Publish the Assay catalog record to each target R2 bucket before deploying this change. The MDX articles themselves are compiled from this repository and require a documentation deployment to update. Catalog changes appear after the 60-second edge cache expires; no documentation rebuild is needed for catalog changes alone.

The two production-facing buckets are **not interchangeable**:

Expand Down Expand Up @@ -102,7 +105,7 @@ Pull requests continue to typecheck, test, build **both** target configurations,

Cloudflare deployment requires repository secrets `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` with the minimum permissions for Workers and the configured custom domains. Newsletter `RESEND_API_KEY` is a **Worker secret**, set independently for the production and staging Workers. The staging `RESEND_SEGMENT_ID` is intentionally empty to prevent accidental subscriptions to the production audience; configure a separate staging segment before testing signup delivery.

Before either deployment, independently confirm the relevant R2 bucket exists, contains a valid `manifest.json` and `products/manifest.json`, is accessible to that Worker's `CONTENT` binding, and that Cloudflare domains and credentials are provisioned. CI cannot create or verify those Cloudflare resources by reading the repository. The deployment smoke tests request the homepage and `/docs` to check real R2 access, plus the LLM, search, robots, sitemap and subscription routes. Staging serves `robots.txt` with `Disallow: /` and sets `X-Robots-Tag: noindex, nofollow, noarchive` on Worker responses.
Before either deployment, independently confirm the relevant R2 bucket exists, contains a valid `manifest.json` and `products/manifest.json`, is accessible to that Worker's `CONTENT` binding, and that Cloudflare domains and credentials are provisioned. CI cannot create or verify those Cloudflare resources by reading the repository. The deployment smoke tests verify both redirects and request `/docs/assay` to check real R2 access, plus the LLM, search, robots, sitemap and subscription routes. Staging serves `robots.txt` with `Disallow: /` and sets `X-Robots-Tag: noindex, nofollow, noarchive` on Worker responses.

## Bundle strategy

Expand Down
10 changes: 10 additions & 0 deletions content/docs/assay/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Assay
description: Compare technical evidence against explicit, versioned criteria.
---

Assay is a library for checking technical evidence against explicit criteria and producing reproducible findings. It runs offline and has no runtime dependencies.

The host supplies evidence and authorizes the criteria. Assay does not execute submitted programs, authenticate observations, assign grades, or issue credentials.

For the source, license, and release information, see the [Assay repository](https://github.com/0xbuffdev/assay).
8 changes: 8 additions & 0 deletions content/docs/assay/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"title": "Assay",
"description": "Compare technical evidence against explicit, versioned criteria.",
"root": true,
"pages": [
"index"
]
}
1 change: 1 addition & 0 deletions content/docs/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"title": "0xBUFF Documentation",
"description": "Guides, examples, and API references for 0xBUFF tools.",
"pages": [
"assay",
"throughline",
"..."
]
Expand Down
3 changes: 2 additions & 1 deletion scripts/docs-navigation.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ test("global navigation lists the first tool and discovers future tools", async
assert.equal(meta.title, "0xBUFF Documentation");
assert.ok(typeof meta.description === "string" && meta.description.trim());
assert.ok(Array.isArray(meta.pages));
assert.equal(meta.pages[0], "throughline");
assert.equal(meta.pages[0], "assay");
assert.ok(meta.pages.includes("throughline"));
assert.equal(meta.pages.at(-1), "...", "Fumadocs must include future tool folders");
assert.equal(new Set(meta.pages).size, meta.pages.length, "duplicate global entries");
for (const entry of meta.pages.filter((name) => name !== "...")) {
Expand Down
114 changes: 17 additions & 97 deletions src/components/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,104 +1,24 @@
import { Button } from "~/components/ui/button";
import { cn } from "~/lib/utils";
import { HomeLayout } from "fumadocs-ui/layouts/home";
import { Link } from "react-router";
import { Crosshair, FrameCrosshairs } from "./crosshair";
import { Footer } from "./footer";
import { baseOptions } from "~/lib/layout.shared";
import { ROUTES } from "~/lib/site";
import { BrandWordmark } from "./brand-wordmark";
import { ROUTES, SITE } from "~/lib/site";

export function NotFoundPage() {
return (
<HomeLayout {...baseOptions()}>
<div className="relative w-full bg-background text-foreground">
<section className="mx-auto max-w-5xl px-4 py-12 sm:px-6 sm:py-20 lg:px-8">
<div className="relative mx-auto w-full max-w-5xl">
{[
"-left-6 -right-6 top-0 origin-center animate-line-x border-t sm:-left-10 sm:-right-10",
"-left-6 -right-6 bottom-0 origin-center animate-line-x border-b sm:-left-10 sm:-right-10",
"-top-6 -bottom-6 left-0 origin-top animate-line-y border-l sm:-top-8 sm:-bottom-8",
"-top-6 -bottom-6 right-0 origin-top animate-line-y border-r sm:-top-8 sm:-bottom-8",
].map((position) => (
<div
key={position}
className={cn(
"pointer-events-none absolute border-dashed border-border/70",
position,
)}
/>
))}
{/* One crosshair at the center of each edge of the hero frame */}
<FrameCrosshairs />

<div
className={cn(
"relative flex items-center justify-between border-x border-t",
"border-dashed border-border px-4 py-2 font-mono text-xs",
"text-muted-foreground backdrop-blur-xs sm:px-6",
)}
>
<span className="font-semibold text-foreground">
~ <code>404</code>
</span>
<span className="hidden text-[10px] tracking-widest uppercase sm:inline">
error / not_found
</span>
</div>

<div className="relative border border-dashed border-border">
<div className="relative px-4 py-8 text-center sm:px-8 sm:py-10">
<div className="flex items-center justify-center gap-2">
<span aria-hidden className="size-1.5 bg-warning" />
<span className="font-mono text-warning text-[0.7rem] font-semibold uppercase tracking-[0.2em]">
404 — Not Found
</span>
</div>
<h1 className="mx-auto mt-3 max-w-3xl text-balance text-4xl font-bold leading-[1.04] tracking-[-0.035em] text-foreground sm:text-5xl lg:text-6xl">
Page not found
</h1>
</div>

<div className="relative border-t border-dashed border-border">
<div className="pointer-events-none absolute inset-x-0 top-0 origin-left animate-line-x border-t border-dashed border-border" />
<Crosshair className="hidden md:block" side="left" />
<Crosshair className="hidden md:block" side="right" />
</div>

<div className="px-4 py-6 text-center sm:px-8 sm:py-7">
<p className="mx-auto max-w-2xl text-balance text-sm leading-relaxed text-muted-foreground sm:text-base">
The page you’re looking for doesn’t exist. It may have been
moved, renamed, or never existed in this memory plane.
</p>
<div className="mt-6 flex flex-wrap items-center justify-center gap-3">
<Button asChild size="lg" className="font-bold tracking-wide">
<Link to={ROUTES.home}>Back to Home</Link>
</Button>
<Button
asChild
variant="secondary"
size="lg"
className="font-bold tracking-wide"
>
<Link to={ROUTES.docs}>Browse Documentation</Link>
</Button>
</div>
</div>
</div>

<div
className={cn(
"relative flex items-center justify-between border-x border-b",
"border-dashed border-border px-4 py-2 font-mono text-[10px]",
"text-muted-foreground/70 backdrop-blur-xs sm:px-6",
)}
>
<span>[status: 404]</span>
<span>[ref: not_found]</span>
</div>
</div>
</section>
<Footer />
<main className="mx-auto flex min-h-dvh max-w-xl flex-col justify-center gap-5 px-6 py-12">
<Link to={ROUTES.docsDefault} className="w-fit font-display font-bold tracking-tight">
<BrandWordmark /> <span className="text-muted-foreground font-normal">/ docs</span>
</Link>
<p className="font-mono text-sm text-muted-foreground">404</p>
<h1 className="text-3xl font-semibold tracking-tight sm:text-4xl">Page not found</h1>
<p className="text-muted-foreground">This documentation page may have moved or no longer exists.</p>
<div className="flex flex-wrap gap-4 text-sm">
<Link className="font-medium text-primary underline underline-offset-4" to={ROUTES.docsDefault}>
Back to documentation
</Link>
<a className="text-muted-foreground underline underline-offset-4" href={SITE.companyUrl}>
0xBUFF website
</a>
</div>
</HomeLayout>
</main>
);
}
16 changes: 16 additions & 0 deletions src/lib/docs-entry.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { redirect } from "react-router";
import { hasDefaultDocsProduct } from "./docs-navigation";
import { ROUTES } from "./site";

export function redirectToDefaultDocs(request: Request, published: readonly { slug: string }[]) {
if (!hasDefaultDocsProduct(published)) {
throw new Response("Default documentation is not published", {
status: 503,
headers: { "Cache-Control": "no-store" },
});
}
return redirect(ROUTES.docsDefault + new URL(request.url).search, {
status: 302,
headers: { "Cache-Control": "no-store" },
});
}
28 changes: 28 additions & 0 deletions src/lib/docs-navigation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import assert from "node:assert/strict";
import test from "node:test";
import type { Root } from "fumadocs-core/page-tree";
import { DEFAULT_DOCS_PRODUCT, filterPublishedProductRoots, hasDefaultDocsProduct } from "./docs-navigation.ts";

test("Assay is the explicit default regardless of catalog ordering", () => {
assert.equal(DEFAULT_DOCS_PRODUCT, "assay");
assert.equal(hasDefaultDocsProduct([{ slug: "throughline" }, { slug: "assay" }]), true);
assert.equal(hasDefaultDocsProduct([{ slug: "assay" }, { slug: "throughline" }]), true);
assert.equal(hasDefaultDocsProduct([{ slug: "throughline" }]), false);
assert.equal(hasDefaultDocsProduct([]), false);
});

test("published product folders retain index-only roots and exclude unpublished roots", () => {
const page = (slug: string) => ({ type: "page" as const, name: slug, url: `/docs/${slug}` });
const tree: Root = {
name: "Docs",
children: [
{ type: "folder", name: "Assay", root: true, index: page("assay"), children: [] },
{ type: "folder", name: "Throughline", root: true, children: [page("throughline")] },
{ type: "folder", name: "Unpublished", root: true, index: page("unpublished"), children: [] },
],
};
const filtered = filterPublishedProductRoots(tree, new Set(["/docs/assay", "/docs/throughline"]));
assert.deepEqual(filtered.children.map((node) => node.name), ["Assay", "Throughline"]);
assert.equal(tree.children.length, 3);
assert.deepEqual(filterPublishedProductRoots(tree, new Set()).children, []);
});
20 changes: 20 additions & 0 deletions src/lib/docs-navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Root } from "fumadocs-core/page-tree";

export const DEFAULT_DOCS_PRODUCT = "assay";

export function hasDefaultDocsProduct(published: readonly { slug: string }[]): boolean {
return published.some(({ slug }) => slug === DEFAULT_DOCS_PRODUCT);
}

/** Keep only authorized product roots, including Fumadocs folder index pages. */
export function filterPublishedProductRoots(tree: Root, availableUrls: ReadonlySet<string>): Root {
const isPublished = (url: string) => availableUrls.has(url.replace(/\/$/, ""));
return {
...tree,
children: tree.children.filter((node) =>
node.type === "folder" &&
((node.index != null && isPublished(node.index.url)) ||
node.children.some((child) => child.type === "page" && isPublished(child.url))),
),
};
}
3 changes: 1 addition & 2 deletions src/lib/layout.shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { PRIMARY_NAVIGATION, ROUTES, SITE } from "./site";
export function baseOptions(): BaseLayoutProps {
return {
nav: {
url: ROUTES.home,
transparentMode: "top",
url: ROUTES.docsDefault,
title: (
<span className="font-display font-bold tracking-tight">
<BrandWordmark />{" "}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/site.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import docsConfig from "./docs-config.json";
import { DEFAULT_DOCS_PRODUCT } from "./docs-navigation";

/**
* Canonical site identity, navigation, and static-route metadata for the docs
Expand Down Expand Up @@ -58,7 +59,7 @@ export const ROUTES = {
home: "/",
docs: "/docs",
/** Default product shown when navigating to /docs. */
docsDefault: "/docs",
docsDefault: `/docs/${DEFAULT_DOCS_PRODUCT}`,
/** Legacy path. Redirected permanently to the canonical company-site manifesto. */
manifesto: "/manifesto",
docsOg: docsConfig.docsImageRoute,
Expand All @@ -73,7 +74,7 @@ export const ROUTES = {
export const PRIMARY_NAVIGATION = [
{
text: "Documentation",
url: ROUTES.docsDefault,
url: ROUTES.docs,
active: "nested-url",
on: "all",
},
Expand Down
4 changes: 4 additions & 0 deletions src/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { NotFoundPage } from "../components/not-found";
import { SITE } from "../lib/site";
import type { Route } from "./+types/$";

export function loader() {
throw new Response("Not found", { status: 404 });
}

export const meta: Route.MetaFunction = () => [
{ title: `Page not found | ${SITE.name}` },
{ name: "robots", content: "noindex, nofollow" },
Expand Down
28 changes: 14 additions & 14 deletions src/routes/docs/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
SITE,
} from "../../lib/site";
import { docs } from "../../lib/docs";
import { filterPublishedProductRoots } from "../../lib/docs-navigation";
import { redirectToDefaultDocs } from "../../lib/docs-entry.server";
import { resolveDocPage, source } from "../../lib/source";
import { getDocumentedProducts } from "../../lib/catalog.server";
import type { Route } from "./+types/$";
Expand All @@ -31,8 +33,7 @@ export async function loader({ params, request, context }: Route.LoaderArgs) {

// Redirect bare /docs to the default product.
if (rawSlug === "" || rawSlug === "/") {
if (!published[0]) throw new Response("No published documentation", { status: 404 });
throw redirect(`${ROUTES.docs}/${published[0].slug}`);
throw redirectToDefaultDocs(request, published);
}

const isMarkdownRequested =
Expand All @@ -53,13 +54,7 @@ export async function loader({ params, request, context }: Route.LoaderArgs) {

const tree = source.getPageTree();
const availableUrls = new Set(published.map(({ slug }) => `${ROUTES.docs}/${slug}`));
const sidebarTree = {
...tree,
children: tree.children.filter((node) =>
node.type === "folder" &&
node.children.some((child) => child.type === "page" && availableUrls.has(child.url.replace(/\/$/, ""))),
),
};
const sidebarTree = filterPublishedProductRoots(tree, availableUrls);

return {
toc: (await page.data.load()).toc as unknown as TOCItemType[],
Expand All @@ -78,11 +73,16 @@ export async function clientLoader({ serverLoader }: Route.ClientLoaderArgs) {
return data;
}

export const meta: Route.MetaFunction = ({ loaderData }) => {
const data = loaderData
export const meta: Route.MetaFunction = ({ loaderData: data }) => {
if (!data) {
return [
{ title: `Documentation unavailable | ${SITE.name}` },
{ name: "robots", content: "noindex, nofollow" },
];
}
return createPageMeta({
title: data.title,
description: data?.description || SITE.description,
description: data.description || SITE.description,
path: data.url,
imagePath: data.imagePath,
});
Expand Down Expand Up @@ -114,7 +114,7 @@ function Content({
>
<DocsTitle>{page.title}</DocsTitle>
<DocsDescription>{page.description}</DocsDescription>
<div className="not-prose my-4 flex flex-row items-center gap-2 border-b border-dashed border-border pb-4">
<div className="not-prose my-4 flex flex-wrap items-center gap-2 border-b border-border pb-4">
<LLMCopyButton markdownUrl={markdownUrl} />
<ViewOptions markdownUrl={markdownUrl} githubUrl={githubUrl} />
</div>
Expand All @@ -125,7 +125,7 @@ function Content({
})}
/>
</DocsBody>
<div className="mt-10 flex flex-wrap items-center justify-between gap-4 border-t border-dashed border-border pt-4 text-xs text-muted-foreground dark:border-border">
<div className="mt-10 flex flex-wrap items-center justify-between gap-4 border-t border-border pt-4 text-xs text-muted-foreground">
<EditOnGitHub href={githubUrl} />
</div>
</DocsPage>
Expand Down
Loading
Loading