CareerChive

How are these docs implemented?

Documentation Build

Documentation Build

How are these docs implemented?

Docs-Only Build

My custom npm run docs script starts Next with FLAG_APP=false so /beck is rewritten to a 404 and the installed CareerChive application is not served.

Defined as a package.json script, npm run docs calls scripts/docs-dev.mjs, which starts the same next dev as npm run dev with FLAG_APP=false set on that process:

Basics & Custom Theme

Documentation styles live in src/app/globals.css. The docs styles work together with:

next.config.ts registers remark-gfm (GitHub-flavoured markdown) and the custom Remark plugin remark-docs-syntax.mjs, which allows:

  • Defining subtitle within a YAML frontmatter block.
  • Using ::: fences for formatting content.
  • Using shortcodes: {.lock} () / {.gear} () / {.select} (SELECT) / {.insert} (INSERT) / {.update} (UPDATE) / {.delete} (DELETE) / {.get} (GET) / {.post} (POST) / {.put} (PUT) / {.patch} (PATCH) / {.button} (button link) / {.blank} (target="_blank") / [text]{.smallcaps} (small caps)

The Remark plugin also pulls page metadata out of the paired content.mdx so page.tsx can import it:

  • title — The # heading, which informs the browser tab. DocsArticle shows it in the page header, and the article hides that first #.
  • frontmatter — The YAML defined at the top of the page. subtitle is the line under that title.
  • toc — ## / ### headings, including headings brought in from a snippet. Headings inside a callout or a tabset are left out.

next.config.ts also registers Rehype (HTML parsing and serialization) plugins:

Documentation Pages

Landing Page

The main documentation landing page (/docs) lives at src/app/(site)/docs/page.tsx, and is built by React, not MDX and hides the sidebar navigation:

  • A .docs-index wrapper styles the landing cards.
  • Card titles and subtitles come from each guide's content.mdx through docs-page-meta.ts.

This landing page:

  • Reads DOCS_NAV_SECTIONS from _nav/docs-nav-data.ts (sidebar navigation).
  • Renders Installation / Guides / Reference / Internal as sections of cards, with Internal in a collapsible group.

Content Pages

Since every guide is wrapped in src/app/(site)/docs/(article)/layout.tsx, the per-page page.tsx defines the rest.

Articles feature a layout inspired by the CareerChive application interface.

API Library

The API Library is a hybrid page (src/app/(site)/docs/(article)/api/page.tsx) — it renders content.mdx, and that file mounts DocsApiExplorer within the article frame, a customized Scalar API explorer.

The explorer catalogs operations from a live PostgREST OpenAPI document. loadDatabaseOpenApi.ts fetches {NEXT_PUBLIC_SUPABASE_URL}/rest/v1/ with SUPABASE_SECRET_KEY so tables without an anon policy still appear. It then drops the docs chatbot tables and the functions that maintain them.

Live OpenAPI

loadDatabaseOpenApi.ts:

  • Caches the fetch (React cache() plus a 60-second revalidate). The API Library loads it when the page, /docs/api/explorer, or /docs/api/catalog is opened.
  • swaggerToOpenApi.ts turns the PostgREST document into OpenAPI 3.1.
  • After fetch it stamps the CareerChive API info title and description, and apikey security on every operation. servers are removed.
  • typesToOpenApi.ts applies that apikey security. apiCatalog.ts turns the same spec into the API search sidebar's tags and operations, using Scalar's tag anchors.

Scalar API Explorer

DocsApiExplorer:

Search & LLM Ingestion

Search opens the shared overlay powered by DocsSearch.tsx:

  • DocsSearchProvider loads /docs/search-index the first time Search opens. Until the index arrives the overlay shows Indexing…. The browser ranks that JSON with MiniSearch.
  • searchTerms.ts expands light English inflections at index and query time (managing ↔ manage), with prefix match and a bit of fuzzy room on longer terms. A heading outranks a title, which outranks the section name, which outranks the body.

What Gets Indexed

  • Host pages only (**/content.mdx); _snippets are never rendered or indexed independently
  • Snippet imports are inlined into the host before flattening headings and body
  • One overview chunk per page, plus one chunk per heading that has body text
  • OpenAPI / Scalar operations are not returned in this search — only docs .mdx files (including /docs/api prose from api/content.mdx)

Accessibility

Along with checking pages with Chrome's Lighthouse accessibility audit, as part of pull request checks, a11y lint runs a spot check on all documentation pages to ensure they are somewhat accessible and any errors discovered are patched before deployment.