feat: add docs site as static Next.js export

Migrates the docs site from remote-config-server to this repo as a
standalone static Next.js app. Key changes:

- Copy app-docs from remote-config-server to docs-site/
- Configure `output: 'export'` for static HTML generation
- Replace API routes with build-time scripts (search index, image copy)
- Add generateStaticParams() to enumerate all doc slugs at build time
- Convert server-side redirects to client-side redirects
- Point DOCS_DIR to sibling ../docs directory
- Add GitHub Actions workflow for deploying to GitHub Pages
- Add missing Radix UI dependencies (accordion, tabs) to package.json

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nate 2026-03-20 13:52:25 -07:00
parent 80ad5a7d71
commit 606fba91a3
42 changed files with 9054 additions and 0 deletions

55
.github/workflows/docs-gh-pages.yml vendored Normal file
View file

@ -0,0 +1,55 @@
name: Deploy Docs to GitHub Pages
on:
push:
branches: [main]
paths:
- "docs/**"
- "docs-site/**"
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: docs-site/package-lock.json
- name: Install dependencies
working-directory: docs-site
run: npm ci
- name: Build
working-directory: docs-site
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs-site/out
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

1
.gitignore vendored
View file

@ -15,6 +15,7 @@ downloads/
eggs/
.eggs/
lib/
!docs-site/lib/
lib64/
parts/
sdist/

5
docs-site/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.next/
out/
node_modules/
public/search-index.json
public/images/docs/

View file

@ -0,0 +1,118 @@
import { compileMDX } from "next-mdx-remote/rsc";
import NotFoundPage from "@/app/components/NotFoundPage";
import { ClientRedirect } from "@/app/components/ClientRedirect";
import { Metadata } from "next/types";
import remarkGfm from "remark-gfm";
import rehypeSlug from "rehype-slug";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypePrismPlus from "rehype-prism-plus";
import { loadMdxFile, getHeadings, getAllDocTitles, getAllDocSlugs, docsNav, resolveDocsRedirect, docsRedirects } from "@/lib/docs";
import { getPageNavigation } from "@/config/docsNav";
import { mdxComponents } from "@/components/docs/mdx";
import { DocsShell } from "@/components/docs/DocsShell";
import { PageNav } from "@/components/docs/PageNav";
import { CopyPageButton } from "@/components/docs/CopyPageButton";
import "../docs.css";
interface Props {
params: Promise<{ slug?: string[] }>;
}
export async function generateStaticParams() {
const docSlugs = getAllDocSlugs();
const params: { slug: string[] }[] = [];
// Root page (index)
params.push({ slug: [] });
// All doc pages from navigation
for (const slug of docSlugs) {
params.push({ slug: slug.split("/") });
}
// All redirect source pages
for (const source of docsRedirects.keys()) {
params.push({ slug: source.split("/") });
}
return params;
}
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = await params;
const doc = await loadMdxFile(slug || ["index"]);
if (!doc) return {};
return {
title: doc.frontmatter.title
? `${doc.frontmatter.title} | Continue Docs`
: "Continue Docs",
description: doc.frontmatter.description || "",
};
}
export default async function DocsPage({ params }: Props) {
const { slug } = await params;
const slugPath = slug || ["index"];
// Check redirect first
const redirectTo = resolveDocsRedirect(slugPath);
if (redirectTo) {
const target = redirectTo.startsWith("http") ? redirectTo : `/docs${redirectTo}`;
return <ClientRedirect to={target} />;
}
const doc = await loadMdxFile(slugPath);
if (!doc) {
return <NotFoundPage />;
}
const headings = getHeadings(doc.content);
const titleMap = getAllDocTitles();
const { content } = await compileMDX({
source: doc.content,
options: {
mdxOptions: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
rehypeSlug,
[
rehypeAutolinkHeadings,
{
behavior: "wrap",
properties: { className: ["heading-anchor"] },
},
],
[rehypePrismPlus, { ignoreMissing: true }],
],
},
},
components: mdxComponents,
});
const currentSlug = (slug || ["index"]).join("/");
const { prev, next } = getPageNavigation(docsNav, currentSlug, titleMap);
return (
<DocsShell currentSlug={currentSlug} headings={headings} titleMap={titleMap} docsNav={docsNav}>
{doc.frontmatter.title && (
<div className="flex items-start justify-between gap-4 mb-2">
<h1 className="text-3xl font-light tracking-tight text-black/90 dark:text-white/90">
{doc.frontmatter.title}
</h1>
<CopyPageButton slug={currentSlug} />
</div>
)}
{doc.frontmatter.description && (
<p className="text-lg text-black/50 dark:text-white/50 mb-8">
{doc.frontmatter.description.replace(/\*\*/g, "")}
</p>
)}
<div className="docs-content max-w-3xl">{content}</div>
<div className="max-w-3xl">
<PageNav prev={prev} next={next} />
</div>
</DocsShell>
);
}

View file

@ -0,0 +1,17 @@
"use client";
import { useEffect } from "react";
export function ClientRedirect({ to }: { to: string }) {
useEffect(() => {
window.location.replace(to);
}, [to]);
return (
<div className="flex items-center justify-center min-h-[60vh]">
<p className="text-sm text-black/40 dark:text-white/40">
Redirecting...
</p>
</div>
);
}

View file

@ -0,0 +1,12 @@
import Link from "next/link";
export default function NotFoundPage() {
return (
<div className="flex flex-col items-center justify-center min-h-[60vh] gap-4">
<h1 className="text-2xl font-light text-black/80 dark:text-white/80">Page not found</h1>
<Link href="/" className="text-sm text-black/40 dark:text-white/40 hover:text-black/70 dark:hover:text-white/70">
Back to docs
</Link>
</div>
);
}

336
docs-site/app/docs.css Normal file
View file

@ -0,0 +1,336 @@
/* Docs content typography — matches homepage palette */
:root {
--docs-text: rgb(0 0 0 / 0.7);
--docs-heading: rgb(0 0 0 / 0.85);
--docs-link: rgb(0 0 0 / 0.8);
--docs-link-underline: rgb(0 0 0 / 0.2);
--docs-link-underline-hover: rgb(0 0 0 / 0.6);
--docs-muted: rgb(0 0 0 / 0.5);
--docs-border: rgb(0 0 0 / 0.1);
--docs-border-light: rgb(0 0 0 / 0.06);
--docs-border-faint: rgb(0 0 0 / 0.05);
--docs-code-bg: rgb(0 0 0 / 0.03);
--docs-code-bg-solid: #f7f7f8;
--docs-code-border: rgb(0 0 0 / 0.06);
--docs-inline-code-bg: rgb(0 0 0 / 0.04);
--docs-anchor: rgb(0 0 0 / 0.2);
--docs-video-bg: rgb(0 0 0 / 0.03);
}
.dark {
--docs-text: rgb(255 255 255 / 0.7);
--docs-heading: rgb(255 255 255 / 0.85);
--docs-link: rgb(255 255 255 / 0.8);
--docs-link-underline: rgb(255 255 255 / 0.2);
--docs-link-underline-hover: rgb(255 255 255 / 0.6);
--docs-muted: rgb(255 255 255 / 0.5);
--docs-border: rgb(255 255 255 / 0.1);
--docs-border-light: rgb(255 255 255 / 0.06);
--docs-border-faint: rgb(255 255 255 / 0.05);
--docs-code-bg: rgb(255 255 255 / 0.05);
--docs-code-bg-solid: #171717;
--docs-code-border: rgb(255 255 255 / 0.06);
--docs-inline-code-bg: rgb(255 255 255 / 0.06);
--docs-anchor: rgb(255 255 255 / 0.2);
--docs-video-bg: rgb(255 255 255 / 0.05);
}
.docs-content {
color: var(--docs-text);
line-height: 1.75;
}
.docs-content h1,
.docs-content h2,
.docs-content h3,
.docs-content h4 {
color: var(--docs-heading);
font-weight: 500;
letter-spacing: -0.01em;
}
.docs-content h1 {
font-size: 2rem;
margin-bottom: 1em;
}
.docs-content h2 {
margin-top: 2.5em;
margin-bottom: 0.75em;
font-size: 1.5rem;
}
.docs-content h3 {
margin-top: 2em;
margin-bottom: 0.5em;
font-size: 1.25rem;
}
.docs-content h4 {
margin-top: 1.5em;
margin-bottom: 0.5em;
font-size: 1.1rem;
}
.docs-content p,
.docs-content .docs-p {
margin-bottom: 1.5em;
}
.docs-content a:not(.no-underline) {
color: var(--docs-link);
text-decoration: underline;
text-underline-offset: 2px;
text-decoration-color: var(--docs-link-underline);
transition: text-decoration-color 0.2s;
}
.docs-content a:not(.no-underline):hover {
text-decoration-color: var(--docs-link-underline-hover);
}
.docs-content blockquote {
border-left: 2px solid var(--docs-border);
padding-left: 1.25em;
color: var(--docs-muted);
font-style: italic;
}
.docs-content hr {
border: none;
border-top: 1px solid var(--docs-border-light);
margin: 2.5em 0;
}
/* Code blocks */
.docs-content pre {
background: var(--docs-code-bg);
border: 1px solid var(--docs-code-border);
border-radius: 6px;
padding: 0.75em 4em 0.75em 1em;
white-space: pre-wrap;
word-wrap: break-word;
font-size: 0.875em;
line-height: 1.6;
font-family: var(--font-geist-mono), ui-monospace, monospace;
margin-bottom: 1.5em;
}
.docs-content code {
font-family: var(--font-geist-mono), ui-monospace, monospace;
font-size: 0.875em;
}
.docs-content :not(pre) > code {
background: var(--docs-inline-code-bg);
padding: 0.15em 0.4em;
border-radius: 3px;
}
/* Tables */
.docs-content table {
width: 100%;
border-collapse: collapse;
margin: 1.5em 0;
font-size: 0.9em;
}
.docs-content th {
text-align: left;
border-bottom: 1px solid var(--docs-border);
padding: 0.75em 1em;
font-weight: 500;
color: var(--docs-heading);
}
.docs-content td {
border-bottom: 1px solid var(--docs-border-faint);
padding: 0.75em 1em;
}
/* Lists */
.docs-content ul {
padding-left: 1.5em;
margin-bottom: 1.5em;
list-style-type: disc;
}
.docs-content ol {
padding-left: 1.5em;
margin-bottom: 1.5em;
list-style-type: decimal;
}
.docs-content li {
margin-bottom: 0.5em;
}
.docs-content li > ul,
.docs-content li > ol {
margin-top: 0.5em;
margin-bottom: 0;
}
/* Images */
.docs-content img {
max-width: 100%;
height: auto;
border-radius: 6px;
margin: 1.5em 0;
}
/* Videos and iframes */
.docs-content iframe {
max-width: 100%;
border-radius: 6px;
margin: 1.5em 0;
}
.docs-content video {
max-width: 100%;
height: auto;
border-radius: 6px;
margin: 1.5em 0;
background: var(--docs-video-bg);
}
/* Syntax highlighting — light GitHub-style theme */
.docs-content .token.comment,
.docs-content .token.prolog,
.docs-content .token.doctype,
.docs-content .token.cdata {
color: #6a737d;
}
.docs-content .token.punctuation {
color: #24292e;
}
.docs-content .token.property,
.docs-content .token.tag,
.docs-content .token.constant,
.docs-content .token.symbol,
.docs-content .token.deleted {
color: #22863a;
}
.docs-content .token.boolean,
.docs-content .token.number {
color: #005cc5;
}
.docs-content .token.selector,
.docs-content .token.attr-name,
.docs-content .token.string,
.docs-content .token.char,
.docs-content .token.builtin,
.docs-content .token.inserted {
color: #032f62;
}
.docs-content .token.operator,
.docs-content .token.entity,
.docs-content .token.url,
.docs-content .language-css .token.string,
.docs-content .style .token.string {
color: #d73a49;
}
.docs-content .token.atrule,
.docs-content .token.attr-value,
.docs-content .token.keyword {
color: #d73a49;
}
.docs-content .token.function,
.docs-content .token.class-name {
color: #6f42c1;
}
.docs-content .token.regex,
.docs-content .token.important,
.docs-content .token.variable {
color: #e36209;
}
.docs-content .token.key {
color: #005cc5;
}
/* Syntax highlighting — dark GitHub-style theme */
.dark .docs-content .token.comment,
.dark .docs-content .token.prolog,
.dark .docs-content .token.doctype,
.dark .docs-content .token.cdata {
color: #8b949e;
}
.dark .docs-content .token.punctuation {
color: #c9d1d9;
}
.dark .docs-content .token.property,
.dark .docs-content .token.tag,
.dark .docs-content .token.constant,
.dark .docs-content .token.symbol,
.dark .docs-content .token.deleted {
color: #7ee787;
}
.dark .docs-content .token.boolean,
.dark .docs-content .token.number {
color: #79c0ff;
}
.dark .docs-content .token.selector,
.dark .docs-content .token.attr-name,
.dark .docs-content .token.string,
.dark .docs-content .token.char,
.dark .docs-content .token.builtin,
.dark .docs-content .token.inserted {
color: #a5d6ff;
}
.dark .docs-content .token.operator,
.dark .docs-content .token.entity,
.dark .docs-content .token.url,
.dark .docs-content .language-css .token.string,
.dark .docs-content .style .token.string {
color: #ff7b72;
}
.dark .docs-content .token.atrule,
.dark .docs-content .token.attr-value,
.dark .docs-content .token.keyword {
color: #ff7b72;
}
.dark .docs-content .token.function,
.dark .docs-content .token.class-name {
color: #d2a8ff;
}
.dark .docs-content .token.regex,
.dark .docs-content .token.important,
.dark .docs-content .token.variable {
color: #ffa657;
}
.dark .docs-content .token.key {
color: #79c0ff;
}
/* Heading anchors from rehype-autolink-headings (behavior: wrap) */
.docs-content h2 > a.heading-anchor,
.docs-content h3 > a.heading-anchor,
.docs-content h4 > a.heading-anchor {
color: inherit;
text-decoration: none !important;
}
.docs-content h2 > a.heading-anchor:hover,
.docs-content h3 > a.heading-anchor:hover,
.docs-content h4 > a.heading-anchor:hover {
text-decoration: none !important;
}

View file

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

42
docs-site/app/layout.tsx Normal file
View file

@ -0,0 +1,42 @@
import type { Metadata } from "next";
import { GeistSans } from "geist/font/sans";
import { GeistMono } from "geist/font/mono";
import { ThemeProvider } from "next-themes";
import "./globals.css";
import "./docs.css";
export const metadata: Metadata = {
title: "Continue Docs",
description: "Documentation for Continue — the open-source AI code assistant.",
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" suppressHydrationWarning>
<head>
<meta name="x-app" content="app-docs" />
</head>
<body>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<div
className={`fixed inset-0 flex flex-col bg-white dark:bg-[#0a0a0a] ${GeistSans.variable} ${GeistMono.variable}`}
style={{
fontFamily: "var(--font-geist-sans), system-ui, sans-serif",
}}
>
<style>{`
.font-mono {
font-family: var(--font-geist-mono), ui-monospace, monospace !important;
}
`}</style>
{children}
</div>
</ThemeProvider>
</body>
</html>
);
}

View file

@ -0,0 +1,28 @@
"use client";
import { useState } from "react";
import { Check, Copy } from "lucide-react";
export function CopyPageButton({ slug }: { slug: string }) {
const [copied, setCopied] = useState(false);
const handleCopy = async () => {
// Copy the visible page content
const content = document.querySelector(".docs-content");
if (content) {
await navigator.clipboard.writeText(content.textContent || "");
setCopied(true);
setTimeout(() => setCopied(false), 2000);
}
};
return (
<button
onClick={handleCopy}
className="flex items-center gap-1.5 px-2 py-1 text-[13px] whitespace-nowrap rounded-md text-black/35 hover:text-black/60 dark:text-white/35 dark:hover:text-white/60 hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors"
>
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
<span>{copied ? "Copied" : "Copy page"}</span>
</button>
);
}

View file

@ -0,0 +1,142 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { useRouter } from "next/navigation";
import { Search } from "lucide-react";
import {
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command";
import { create, load, search, type AnyOrama } from "@orama/orama";
interface SearchResult {
title: string;
path: string;
content: string;
section: string;
}
export function DocsSearch({ resolve }: { resolve: (path: string) => string }) {
const [open, setOpen] = useState(false);
const [query, setQuery] = useState("");
const [results, setResults] = useState<SearchResult[]>([]);
const [allDocs, setAllDocs] = useState<SearchResult[]>([]);
const [loading, setLoading] = useState(false);
const dbRef = useRef<AnyOrama | null>(null);
const router = useRouter();
// Cmd+K keyboard shortcut
useEffect(() => {
function onKeyDown(e: KeyboardEvent) {
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
setOpen((prev) => !prev);
}
}
document.addEventListener("keydown", onKeyDown);
return () => document.removeEventListener("keydown", onKeyDown);
}, []);
useEffect(() => {
if (!open || dbRef.current) return;
setLoading(true);
fetch("/search-index.json")
.then((res) => res.json())
.then((data) => {
const db = create({
schema: {
title: "string" as const,
path: "string" as const,
content: "string" as const,
section: "string" as const,
},
});
load(db, data);
dbRef.current = db;
// Get all docs for showing when query is empty
const allResult = search(db, { term: "", limit: 100 });
const toResults = (r: typeof allResult) =>
(r as Awaited<typeof allResult>).hits.map((hit: { document: unknown }) => hit.document as SearchResult);
setAllDocs(toResults(allResult));
})
.finally(() => setLoading(false));
}, [open]);
// Search when query changes
useEffect(() => {
if (!dbRef.current || !query.trim()) {
setResults([]);
return;
}
const res = search(dbRef.current, {
term: query,
limit: 10,
tolerance: 1,
boost: { title: 3, section: 1.5 },
}) as Awaited<ReturnType<typeof search>>;
setResults(res.hits.map((hit: { document: unknown }) => hit.document as SearchResult));
}, [query]);
const displayResults = query.trim() ? results : allDocs;
function handleSelect(path: string) {
setOpen(false);
setQuery("");
router.push(resolve(`/docs/${path}`));
}
return (
<>
<button
onClick={() => setOpen(true)}
className="flex items-center gap-2 w-full max-w-md h-9 rounded-lg border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.04] px-3 text-[13px] text-black/40 dark:text-white/40 hover:border-black/20 dark:hover:border-white/20 transition-colors"
>
<Search className="h-4 w-4 flex-shrink-0" />
<span className="flex-1 text-left">Search...</span>
<kbd className="hidden sm:inline-flex h-5 items-center gap-0.5 rounded border border-black/10 dark:border-white/10 bg-black/[0.03] dark:bg-white/[0.06] px-1.5 font-mono text-[10px] text-black/40 dark:text-white/40">
<span className="text-xs">&#8984;</span>K
</kbd>
</button>
<CommandDialog open={open} onOpenChange={setOpen} dialogClassName="top-[15%] translate-y-0 data-[state=closed]:slide-out-to-top-[10%] data-[state=open]:slide-in-from-top-[10%]">
<CommandInput
placeholder="Search documentation..."
value={query}
onValueChange={setQuery}
/>
<CommandList className="max-h-[400px]">
{loading ? (
<div className="py-6 text-center text-sm text-muted-foreground">
Loading search index...
</div>
) : (
<>
<CommandEmpty>No results found.</CommandEmpty>
{displayResults.length > 0 && (
<CommandGroup heading={query.trim() ? "Results" : "All pages"}>
{displayResults.map((result) => (
<CommandItem
key={result.path}
value={result.path}
onSelect={() => handleSelect(result.path)}
>
<div className="flex flex-col gap-0.5">
<span className="font-medium">{result.title}</span>
<span className="text-xs text-muted-foreground line-clamp-1">
{result.content.slice(0, 120)}
</span>
</div>
</CommandItem>
))}
</CommandGroup>
)}
</>
)}
</CommandList>
</CommandDialog>
</>
);
}

View file

@ -0,0 +1,402 @@
"use client";
import { useEffect, useState } from "react";
import Link from "next/link";
import { ChevronDown, Menu, Moon, Sun, X } from "lucide-react";
import { useTheme } from "next-themes";
import { type NavGroup, type NavItem, type NavTab } from "@/config/docsNav";
import { TableOfContents } from "./TableOfContents";
import { DocsSearch } from "./DocsSearch";
import { resolveHref } from "@/lib/resolveHref";
import type { Heading } from "@/lib/docs";
/* ------------------------------------------------------------------ */
/* Helpers */
/* ------------------------------------------------------------------ */
function containsSlug(group: NavGroup, slug: string): boolean {
return group.pages.some((item) => {
if (typeof item === "string") return item === slug;
return containsSlug(item, slug);
});
}
function findActiveTab(nav: NavTab[], slug: string) {
for (const tab of nav) {
for (const group of tab.groups) {
if (containsSlug(group, slug)) {
return tab;
}
}
}
return nav[nav.length - 1];
}
function slugToLabel(slug: string, titleMap?: Record<string, string>) {
if (titleMap?.[slug]) return titleMap[slug];
const name = slug.split("/").pop() || slug;
return name
.replace(/^\d+-/, "")
.replace(/-/g, " ")
.replace(/\b\w/g, (l) => l.toUpperCase());
}
/* ------------------------------------------------------------------ */
/* Top nav constants */
/* ------------------------------------------------------------------ */
const NAV_LINK_DEFS = [
{ label: "Docs", path: "/docs" },
{ label: "Blog", path: "/blog" },
];
const NAV_LINKS = NAV_LINK_DEFS.map((d) => ({
label: d.label,
href: resolveHref(d.path),
}));
const NAV_LINK_CLASSES =
"text-[13px] text-black/40 dark:text-white/40 hover:text-black/70 dark:hover:text-white/70 transition-colors tracking-wide uppercase font-mono";
const SIDEBAR_W = "w-64"; // shared sidebar width token
function ThemeToggle() {
const { resolvedTheme, setTheme } = useTheme();
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) {
return <div className="w-8 h-8" />;
}
return (
<button
onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
className="p-2 text-black/40 dark:text-white/40 hover:text-black/70 dark:hover:text-white/70 transition-colors"
aria-label="Toggle theme"
>
{resolvedTheme === "dark" ? (
<Moon className="h-4 w-4" />
) : (
<Sun className="h-4 w-4" />
)}
</button>
);
}
/* ------------------------------------------------------------------ */
/* Sidebar primitives */
/* ------------------------------------------------------------------ */
function SidebarGroup({
group,
currentSlug,
titleMap,
resolve,
depth = 0,
}: {
group: NavGroup;
currentSlug: string;
titleMap?: Record<string, string>;
resolve: (path: string) => string;
depth?: number;
}) {
const isActive = containsSlug(group, currentSlug);
const [open, setOpen] = useState(group.expanded === true || isActive);
// Top-level groups are static section headers (always open, not toggleable)
if (depth === 0) {
return (
<div>
<div className="py-2 text-[11px] font-semibold uppercase tracking-wider text-black/50 dark:text-white/50">
{group.group}
</div>
<div className="space-y-0.5">
{group.pages.map((item, i) => (
<SidebarItem
key={i}
item={item}
currentSlug={currentSlug}
titleMap={titleMap}
resolve={resolve}
depth={depth + 1}
/>
))}
</div>
</div>
);
}
return (
<div>
<button
onClick={() => setOpen(!open)}
className="flex w-full items-center justify-between py-1.5 px-2.5 -mx-2.5 text-[13px] text-black/45 dark:text-white/45 hover:text-black/70 dark:hover:text-white/70"
>
<span>{group.group}</span>
<ChevronDown
className={`h-3.5 w-3.5 text-black/30 dark:text-white/30 transition-transform ${
open ? "rotate-0" : "-rotate-90"
}`}
/>
</button>
{open && (
<div className="ml-3 border-l border-black/[0.06] dark:border-white/[0.06] pl-3 space-y-0.5">
{group.pages.map((item, i) => (
<SidebarItem
key={i}
item={item}
currentSlug={currentSlug}
titleMap={titleMap}
resolve={resolve}
depth={depth + 1}
/>
))}
</div>
)}
</div>
);
}
function SidebarItem({
item,
currentSlug,
titleMap,
resolve,
depth = 0,
}: {
item: NavItem;
currentSlug: string;
titleMap?: Record<string, string>;
resolve: (path: string) => string;
depth?: number;
}) {
if (typeof item === "string") {
const isActive = item === currentSlug;
return (
<Link
href={resolve(`/docs/${item}`)}
className={`block py-1.5 px-2.5 -mx-2.5 rounded text-[13px] transition-colors no-underline ${
isActive
? "text-black/90 dark:text-white/90 font-medium bg-black/[0.04] dark:bg-white/[0.06]"
: "text-black/45 dark:text-white/45 hover:text-black/70 dark:hover:text-white/70"
}`}
>
{slugToLabel(item, titleMap)}
</Link>
);
}
return (
<SidebarGroup group={item} currentSlug={currentSlug} titleMap={titleMap} resolve={resolve} depth={depth} />
);
}
/* ------------------------------------------------------------------ */
/* Main shell */
/* ------------------------------------------------------------------ */
export function DocsShell({
currentSlug,
headings,
titleMap,
docsNav,
children,
}: {
currentSlug: string;
headings: Heading[];
titleMap?: Record<string, string>;
docsNav: NavTab[];
children: React.ReactNode;
}) {
const activeTab = findActiveTab(docsNav, currentSlug) ?? docsNav[0]!;
const [selectedTab, setSelectedTab] = useState(activeTab.tab);
const [mobileOpen, setMobileOpen] = useState(false);
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const currentTab =
docsNav.find((t) => t.tab === selectedTab) ?? docsNav[0]!;
const navLinks = NAV_LINKS;
return (
<div className="flex flex-col h-full">
{/* ---- Header: nav + tabs ---- */}
<div className="flex-shrink-0 z-30 bg-white dark:bg-[#0a0a0a]">
{/* Top nav bar */}
<nav className="border-b border-black/[0.06] dark:border-white/[0.06]">
<div className="flex items-center max-w-[90rem] mx-auto">
{/* Logo — same width & padding as sidebar */}
<div className={`hidden lg:flex items-center ${SIDEBAR_W} flex-shrink-0 px-5 py-3`}>
<Link href={resolveHref("/")} className="flex items-center">
<img
src="/images/continue-logo-light.png"
alt="Continue"
className="h-8 w-auto dark:invert"
/>
</Link>
</div>
{/* Mobile logo */}
<div className="lg:hidden flex items-center px-5 py-3">
<Link href={resolveHref("/")} className="flex items-center">
<img
src="/images/continue-logo-light.png"
alt="Continue"
className="h-8 w-auto dark:invert"
/>
</Link>
</div>
{/* Centered search */}
<div className="flex-1 flex items-center justify-center px-5 py-3">
<DocsSearch resolve={resolveHref} />
</div>
{/* Right nav */}
<div className="flex items-center gap-6 px-5 py-3">
<div className="hidden md:flex items-center gap-6">
{navLinks.map((link) => (
<Link
key={link.label}
href={link.href}
className={`${NAV_LINK_CLASSES} ${
link.label === "Docs" ? "text-black/70 dark:text-white/70" : ""
}`}
>
{link.label}
</Link>
))}
<Link href={resolveHref("/login")} className={NAV_LINK_CLASSES}>
Sign in
</Link>
</div>
<ThemeToggle />
{/* Mobile menu button */}
<button
className="md:hidden p-2 text-black/40 dark:text-white/40 hover:text-black/70 dark:hover:text-white/70 transition-colors"
onClick={() => setMobileMenuOpen((prev) => !prev)}
aria-label="Toggle menu"
>
{mobileMenuOpen ? (
<X className="w-5 h-5" />
) : (
<Menu className="w-5 h-5" />
)}
</button>
</div>
</div>
{mobileMenuOpen && (
<div className="md:hidden flex flex-col gap-4 px-5 pt-4 pb-2">
{navLinks.map((link) => (
<Link
key={link.label}
href={link.href}
className={NAV_LINK_CLASSES}
onClick={() => setMobileMenuOpen(false)}
>
{link.label}
</Link>
))}
<Link
href={resolveHref("/login")}
className={NAV_LINK_CLASSES}
onClick={() => setMobileMenuOpen(false)}
>
Sign in
</Link>
</div>
)}
</nav>
{/* Tab bar — aligned with sidebar */}
<div className="border-b border-black/[0.06] dark:border-white/[0.06]">
<div className="max-w-[90rem] mx-auto px-5 flex gap-6">
{docsNav.map((tab) => (
<button
key={tab.tab}
onClick={() => setSelectedTab(tab.tab)}
className={`relative py-2.5 text-sm font-medium transition-colors ${
selectedTab === tab.tab
? "text-black/80 dark:text-white/80"
: "text-black/35 dark:text-white/35 hover:text-black/60 dark:hover:text-white/60"
}`}
>
{tab.tab}
{selectedTab === tab.tab && (
<span className="absolute bottom-0 left-0 right-0 h-[2px] bg-black/70 dark:bg-white/70 rounded-full" />
)}
</button>
))}
</div>
</div>
</div>
{/* ---- Content area ---- */}
<div className="flex-1 min-h-0 flex w-full max-w-[90rem] mx-auto">
{/* Desktop sidebar */}
<aside className={`hidden lg:block ${SIDEBAR_W} flex-shrink-0 border-r border-black/[0.06] dark:border-white/[0.06] overflow-y-auto pt-5 pb-8 px-5`}>
<nav className="space-y-5">
{currentTab.groups.map((group, i) => (
<SidebarGroup key={i} group={group} currentSlug={currentSlug} titleMap={titleMap} resolve={resolveHref} />
))}
</nav>
</aside>
{/* Main content */}
<main className="flex-1 min-w-0 overflow-y-auto px-8 pt-10 pb-8 lg:px-20">{children}</main>
{/* Table of contents */}
<TableOfContents headings={headings} />
</div>
{/* ---- Mobile sidebar ---- */}
<button
className="lg:hidden fixed bottom-4 left-4 z-50 p-3 bg-black/80 dark:bg-white/80 text-white dark:text-black rounded-full shadow-lg"
onClick={() => setMobileOpen(!mobileOpen)}
aria-label="Toggle sidebar"
>
{mobileOpen ? (
<X className="h-5 w-5" />
) : (
<Menu className="h-5 w-5" />
)}
</button>
{mobileOpen && (
<>
<div
className="lg:hidden fixed inset-0 z-40 bg-black/20 dark:bg-black/50"
onClick={() => setMobileOpen(false)}
/>
<aside className="lg:hidden fixed inset-y-0 left-0 z-40 w-72 bg-white dark:bg-[#0a0a0a] border-r border-black/[0.06] dark:border-white/[0.06] overflow-y-auto pt-4 pb-8 px-4 shadow-xl">
<div className="flex gap-4 mb-4 border-b border-black/[0.06] dark:border-white/[0.06] pb-2">
{docsNav.map((tab) => (
<button
key={tab.tab}
onClick={() => setSelectedTab(tab.tab)}
className={`relative pb-2 text-sm font-medium transition-colors ${
selectedTab === tab.tab
? "text-black/80 dark:text-white/80"
: "text-black/35 dark:text-white/35 hover:text-black/60 dark:hover:text-white/60"
}`}
>
{tab.tab}
{selectedTab === tab.tab && (
<span className="absolute bottom-0 left-0 right-0 h-[2px] bg-black/70 dark:bg-white/70 rounded-full" />
)}
</button>
))}
</div>
<nav className="space-y-3">
{currentTab.groups.map((group, i) => (
<SidebarGroup
key={i}
group={group}
currentSlug={currentSlug}
titleMap={titleMap}
resolve={resolveHref}
/>
))}
</nav>
</aside>
</>
)}
</div>
);
}

View file

@ -0,0 +1,42 @@
"use client";
import Link from "next/link";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { resolveHref } from "@/lib/resolveHref";
export function PageNav({
prev,
next,
}: {
prev: { slug: string; title: string } | null;
next: { slug: string; title: string } | null;
}) {
if (!prev && !next) return null;
return (
<div className="flex justify-between items-center mt-16 pt-6 border-t border-black/[0.06] dark:border-white/[0.06]">
{prev ? (
<Link
href={resolveHref(`/docs/${prev.slug}`)}
className="flex items-center gap-2 text-sm text-black/40 dark:text-white/40 hover:text-black/70 dark:hover:text-white/70 transition-colors no-underline"
>
<ChevronLeft className="h-4 w-4" />
<span>{prev.title}</span>
</Link>
) : (
<div />
)}
{next ? (
<Link
href={resolveHref(`/docs/${next.slug}`)}
className="flex items-center gap-2 text-sm text-black/40 dark:text-white/40 hover:text-black/70 dark:hover:text-white/70 transition-colors no-underline"
>
<span>{next.title}</span>
<ChevronRight className="h-4 w-4" />
</Link>
) : (
<div />
)}
</div>
);
}

View file

@ -0,0 +1,59 @@
"use client";
import { useEffect, useState } from "react";
import type { Heading } from "@/lib/docs";
export function TableOfContents({ headings }: { headings: Heading[] }) {
const [activeId, setActiveId] = useState<string>("");
useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
for (const entry of entries) {
if (entry.isIntersecting) {
setActiveId(entry.target.id);
}
}
},
{ rootMargin: "0px 0px -80% 0px", threshold: 0 },
);
for (const heading of headings) {
const el = document.getElementById(heading.id);
if (el) observer.observe(el);
}
return () => observer.disconnect();
}, [headings]);
if (headings.length === 0) return null;
return (
<aside className="hidden xl:block w-56 flex-shrink-0 pt-8 pb-8 px-4 overflow-y-auto">
<h4 className="text-xs font-medium uppercase tracking-wider text-black/30 dark:text-white/30 mb-3">
On this page
</h4>
<nav className="space-y-1">
{headings.map((heading) => (
<a
key={heading.id}
href={`#${heading.id}`}
className={`block text-[13px] transition-colors py-1 ${
heading.level === 3
? "pl-3"
: heading.level === 4
? "pl-6"
: ""
} ${
activeId === heading.id
? "text-black/80 dark:text-white/80 font-medium"
: "text-black/35 dark:text-white/35 hover:text-black/60 dark:hover:text-white/60"
}`}
>
{heading.text}
</a>
))}
</nav>
</aside>
);
}

View file

@ -0,0 +1,48 @@
import { Info, Lightbulb, AlertTriangle, FileText } from "lucide-react";
const variants = {
info: {
icon: Info,
borderColor: "border-blue-400",
bgColor: "bg-blue-50 dark:bg-blue-950",
iconColor: "text-blue-500",
},
tip: {
icon: Lightbulb,
borderColor: "border-green-400",
bgColor: "bg-green-50 dark:bg-green-950",
iconColor: "text-green-500",
},
warning: {
icon: AlertTriangle,
borderColor: "border-amber-400",
bgColor: "bg-amber-50 dark:bg-amber-950",
iconColor: "text-amber-500",
},
note: {
icon: FileText,
borderColor: "border-gray-400",
bgColor: "bg-gray-50 dark:bg-gray-950",
iconColor: "text-gray-500",
},
};
export function Callout({
variant = "info",
children,
}: {
variant?: keyof typeof variants;
children: React.ReactNode;
}) {
const config = variants[variant] || variants.info;
const Icon = config.icon;
return (
<div
className={`my-4 flex gap-3 border-l-4 ${config.borderColor} ${config.bgColor} p-4 rounded-r-md`}
>
<Icon className={`h-5 w-5 mt-0.5 flex-shrink-0 ${config.iconColor}`} />
<div className="flex-1 text-sm [&>p:last-child]:mb-0">{children}</div>
</div>
);
}

View file

@ -0,0 +1,79 @@
"use client";
import Link from "next/link";
import { resolveHref } from "@/lib/resolveHref";
export function CardGroup({
cols = 2,
children,
}: {
cols?: number;
children: React.ReactNode;
}) {
const colClasses = {
1: "grid-cols-1",
2: "grid-cols-1 sm:grid-cols-2",
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
};
const colClass = colClasses[Math.min(cols, 4) as 1 | 2 | 3 | 4] || colClasses[2];
return (
<div className={`my-6 grid gap-4 ${colClass}`}>
{children}
</div>
);
}
export function Card({
title,
icon,
href,
children,
}: {
title: string;
icon?: string;
href?: string;
children?: React.ReactNode;
}) {
const inner = (
<div className={`rounded-lg border border-black/[0.08] dark:border-white/[0.08] bg-white dark:bg-white/5 p-5 h-full${href ? " transition-colors hover:border-black/[0.18] dark:hover:border-white/[0.18]" : ""}`}>
{title && (
<h3 className="text-[15px] font-medium text-black/80 dark:text-white/80 mb-1 !mt-0">
{title}
</h3>
)}
{children && <div className="text-sm text-black/50 dark:text-white/50">{children}</div>}
</div>
);
const resolve = resolveHref;
if (href) {
const isExternal = href.startsWith("http");
if (isExternal) {
return (
<a
href={href}
target="_blank"
rel="noopener noreferrer"
className="no-underline !text-inherit"
>
{inner}
</a>
);
}
const internalPath = href.startsWith("/docs") ? href : `/docs${href}`;
const resolved = resolve(internalPath);
return (
<Link href={resolved} className="no-underline !text-inherit">
{inner}
</Link>
);
}
return inner;
}

View file

@ -0,0 +1,80 @@
"use client";
import { useRef, useState } from "react";
// Hoisted static SVG elements to avoid recreation on every render (Rule 6.2)
const checkIcon = (
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<polyline points="20 6 9 17 4 12" />
</svg>
);
const copyIcon = (
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
</svg>
);
export function CodeBlock({
children,
...props
}: {
children: React.ReactNode;
className?: string;
}) {
const preRef = useRef<HTMLPreElement>(null);
const [copied, setCopied] = useState(false);
const handleCopy = () => {
const text = preRef.current?.textContent || "";
navigator.clipboard.writeText(text).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 2000);
});
};
return (
<div className="relative">
<pre ref={preRef} {...props}>
{children}
</pre>
{/* Overlay: inset matches pre's border (1px) so gradient fills to the edge */}
<div className="absolute inset-[1px] pointer-events-none flex items-start justify-end rounded-[5px] overflow-hidden">
<div
className="pointer-events-auto flex items-start pt-2 pl-8"
style={{
background:
"linear-gradient(to right, transparent, var(--docs-code-bg-solid) 40%)",
}}
>
<button
onClick={handleCopy}
className="mr-2 p-1.5 rounded-md text-black/30 dark:text-white/30 hover:text-black/60 dark:hover:text-white/60 hover:bg-black/[0.06] dark:hover:bg-white/[0.08] transition-colors"
aria-label="Copy code"
>
{copied ? checkIcon : copyIcon}
</button>
</div>
</div>
</div>
);
}

View file

@ -0,0 +1,75 @@
"use client";
import * as TabsPrimitive from "@radix-ui/react-tabs";
import React, { Children, isValidElement } from "react";
/**
* CodeGroup renders multiple code blocks as tabs.
* Tab labels are derived from code block data-title attributes
* or fall back to "Tab 1", "Tab 2", etc.
*/
export function CodeGroup({ children }: { children: React.ReactNode }) {
const blocks: { label: string; content: React.ReactNode }[] = [];
Children.forEach(children, (child) => {
if (!isValidElement(child)) return;
// After MDX compilation, each code block is wrapped by CodeBlock (a div > pre > code)
// Try to find a label from props
const props = child.props as Record<string, any>;
let label = props["data-title"] || props.title || "";
if (!label && props.children) {
// Try to find label from the inner pre/code className
const text = extractTextContent(child);
// Guess label from package manager command (check longer names first)
if (text.includes("pnpm ")) label = "pnpm";
else if (text.includes("yarn ")) label = "yarn";
else if (text.includes("npm ")) label = "npm";
else if (text.includes("bun ")) label = "bun";
else if (text.includes("brew ")) label = "brew";
else if (text.includes("pip ")) label = "pip";
else if (text.includes("cargo ")) label = "cargo";
}
if (!label) label = `Tab ${blocks.length + 1}`;
blocks.push({ label, content: child });
});
if (blocks.length === 0) return <>{children}</>;
if (blocks.length === 1) return <>{blocks[0]!.content}</>;
return (
<TabsPrimitive.Root defaultValue="0" className="my-4">
<TabsPrimitive.List className="flex border-b border-black/[0.08] dark:border-white/[0.08]">
{blocks.map((block, i) => (
<TabsPrimitive.Trigger
key={i}
value={String(i)}
className="px-4 py-2 text-sm text-black/40 dark:text-white/40 data-[state=active]:text-black/80 dark:data-[state=active]:text-white/80 data-[state=active]:border-b-2 data-[state=active]:border-black/80 dark:data-[state=active]:border-white/80 transition-colors -mb-px"
>
{block.label}
</TabsPrimitive.Trigger>
))}
</TabsPrimitive.List>
{blocks.map((block, i) => (
<TabsPrimitive.Content key={i} value={String(i)} className="pt-2">
{block.content}
</TabsPrimitive.Content>
))}
</TabsPrimitive.Root>
);
}
function extractTextContent(element: React.ReactElement): string {
const props = element.props as Record<string, any>;
if (typeof props.children === "string") return props.children;
if (Array.isArray(props.children)) {
return props.children
.map((c: any) => (typeof c === "string" ? c : isValidElement(c) ? extractTextContent(c) : ""))
.join("");
}
if (isValidElement(props.children)) {
return extractTextContent(props.children);
}
return "";
}

View file

@ -0,0 +1,21 @@
export function Columns({
cols = 2,
children,
}: {
cols?: number;
children: React.ReactNode;
}) {
const colClasses = {
1: "grid-cols-1",
2: "grid-cols-1 sm:grid-cols-2",
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
};
const colClass = colClasses[Math.min(cols, 4) as 1 | 2 | 3 | 4] || colClasses[2];
return (
<div className={`my-6 grid gap-6 ${colClass}`}>
{children}
</div>
);
}

View file

@ -0,0 +1,88 @@
"use client";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { ChevronDown } from "lucide-react";
import React, { Children, isValidElement } from "react";
export function DocsAccordionGroup({
children,
}: {
children: React.ReactNode;
}) {
// Collect accordion items and assign unique values
const items: { title: string; content: React.ReactNode; value: string }[] =
[];
Children.forEach(children, (child, i) => {
if (isValidElement(child)) {
const props = child.props as Record<string, any>;
if (props.title) {
items.push({
title: props.title,
content: props.children,
value: `item-${i}`,
});
}
}
});
if (items.length === 0) return <>{children}</>;
return (
<AccordionPrimitive.Root
type="single"
collapsible
className="my-4 rounded-lg border border-black/[0.06] dark:border-white/[0.06] overflow-hidden"
>
{items.map((item, i) => (
<AccordionPrimitive.Item
key={item.value}
value={item.value}
className={
i > 0
? "border-t border-black/[0.06] dark:border-white/[0.06]"
: ""
}
>
<AccordionPrimitive.Trigger className="flex w-full items-center justify-between px-4 py-3 text-sm font-medium text-black/70 dark:text-white/70 hover:text-black/90 dark:hover:text-white/90 transition-colors [&[data-state=open]>svg]:rotate-180">
{item.title}
<ChevronDown className="h-4 w-4 flex-shrink-0 text-black/30 dark:text-white/30 transition-transform duration-200" />
</AccordionPrimitive.Trigger>
<AccordionPrimitive.Content className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down">
<div className="px-4 pb-4 text-black/60 dark:text-white/60">
{item.content}
</div>
</AccordionPrimitive.Content>
</AccordionPrimitive.Item>
))}
</AccordionPrimitive.Root>
);
}
export function DocsAccordion({
title,
children,
}: {
title: string;
children: React.ReactNode;
}) {
// Standalone accordion (not inside a group)
return (
<AccordionPrimitive.Root
type="single"
collapsible
className="my-4 rounded-lg border border-black/[0.06] dark:border-white/[0.06] overflow-hidden"
>
<AccordionPrimitive.Item value="item">
<AccordionPrimitive.Trigger className="flex w-full items-center justify-between px-4 py-3 text-sm font-medium text-black/70 dark:text-white/70 hover:text-black/90 dark:hover:text-white/90 transition-colors [&[data-state=open]>svg]:rotate-180">
{title}
<ChevronDown className="h-4 w-4 flex-shrink-0 text-black/30 dark:text-white/30 transition-transform duration-200" />
</AccordionPrimitive.Trigger>
<AccordionPrimitive.Content className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down">
<div className="px-4 pb-4 text-black/60 dark:text-white/60">
{children}
</div>
</AccordionPrimitive.Content>
</AccordionPrimitive.Item>
</AccordionPrimitive.Root>
);
}

View file

@ -0,0 +1,55 @@
"use client";
import * as TabsPrimitive from "@radix-ui/react-tabs";
import React, { Children, isValidElement } from "react";
export function DocsTabs({ children }: { children: React.ReactNode }) {
const tabs: { title: string; content: React.ReactNode }[] = [];
Children.forEach(children, (child) => {
if (isValidElement(child)) {
const props = child.props as Record<string, any>;
// Check for title prop — the signature of a Tab child.
// We can't rely on displayName across the RSC serialization boundary.
if ("title" in props) {
tabs.push({
title: props.title || `Tab ${tabs.length + 1}`,
content: props.children,
});
}
}
});
if (tabs.length === 0) return <>{children}</>;
return (
<TabsPrimitive.Root defaultValue="0" className="my-4">
<TabsPrimitive.List className="flex border-b border-black/[0.08] dark:border-white/[0.08]">
{tabs.map((tab, i) => (
<TabsPrimitive.Trigger
key={i}
value={String(i)}
className="px-4 py-2 text-sm text-black/40 dark:text-white/40 data-[state=active]:text-black/80 dark:data-[state=active]:text-white/80 data-[state=active]:border-b-2 data-[state=active]:border-black/80 dark:data-[state=active]:border-white/80 transition-colors -mb-px"
>
{tab.title}
</TabsPrimitive.Trigger>
))}
</TabsPrimitive.List>
{tabs.map((tab, i) => (
<TabsPrimitive.Content key={i} value={String(i)} className="pt-4">
{tab.content}
</TabsPrimitive.Content>
))}
</TabsPrimitive.Root>
);
}
export function DocsTab({
children,
}: {
title?: string;
children: React.ReactNode;
}) {
return <>{children}</>;
}
DocsTab.displayName = "DocsTab";

View file

@ -0,0 +1,18 @@
import { resolveHref } from "@/lib/resolveHref";
export function MdxLink({
href,
children,
...props
}: React.AnchorHTMLAttributes<HTMLAnchorElement>) {
if (href?.startsWith("/")) {
const internalPath = href.startsWith("/docs") ? href : `/docs${href}`;
href = resolveHref(internalPath);
}
return (
<a href={href} {...props}>
{children}
</a>
);
}

View file

@ -0,0 +1,162 @@
const modelRecs: Record<
string,
{ open: string[]; closed: string[]; notes: string }
> = {
agent_plan: {
open: [
"[Qwen3 Coder (480B)](https://continue.dev/openrouter/qwen3-coder)",
"[Qwen3 Coder (30B)](https://continue.dev/ollama/qwen3-coder-30b)",
"[Devstral (27B)](https://continue.dev/ollama/devstral)",
"[Kimi K2 (1T)](https://continue.dev/openrouter/kimi-k2)",
],
closed: [
"[Claude Opus 4.1](https://continue.dev/anthropic/claude-4-1-opus)",
"[Claude Sonnet 4.6](https://continue.dev/anthropic/claude-sonnet-4-6)",
"[GPT-5](https://continue.dev/openai/gpt-5)",
"[Gemini 2.5 Pro](https://continue.dev/google/gemini-2.5-pro)",
],
notes: "Closed models are slightly better than open models",
},
chat_edit: {
open: [
"[Qwen3 Coder (480B)](https://continue.dev/openrouter/qwen3-coder)",
"[Qwen3 Coder (30B)](https://continue.dev/ollama/qwen3-coder-30b)",
],
closed: [
"[Claude Opus 4.1](https://continue.dev/anthropic/claude-4-1-opus)",
"[Claude Sonnet 4.6](https://continue.dev/anthropic/claude-sonnet-4-6)",
"[GPT-5](https://continue.dev/openai/gpt-5)",
"[Gemini 2.5 Pro](https://continue.dev/google/gemini-2.5-pro)",
],
notes: "Closed and open models have similar performance",
},
autocomplete: {
open: [
"[QwenCoder2.5 (1.5B)](https://continue.dev/ollama/qwen2.5-coder-1.5b)",
"[QwenCoder2.5 (7B)](https://continue.dev/ollama/qwen2.5-coder-7b)",
],
closed: [
"[Codestral](https://continue.dev/mistral/codestral)",
"[Mercury Coder](https://continue.dev/inception/mercury-coder)",
],
notes: "Closed models are slightly better than open models",
},
apply: {
open: ["[FastApply](https://continue.dev/mdpauley/fast-apply-15b-v10)"],
closed: [
"[Relace Instant Apply](https://continue.dev/relace/instant-apply)",
"[Morph Fast Apply](https://continue.dev/morphllm/morph-v2)",
],
notes: "Closed models are better than open models",
},
embed: {
open: [
"[Nomic Embed Text](https://continue.dev/ollama/nomic-embed-text-latest)",
],
closed: [
"[Voyage Code 3](https://continue.dev/voyageai/voyage-code-3)",
"[Morph Embeddings](https://continue.dev/morphllm/morph-embedding-v2)",
],
notes: "Closed models are slightly better than open models",
},
rerank: {
open: ["zerank-1", "zerank-1-small"],
closed: [
"[Voyage Rerank 2.5](https://continue.dev/voyageai/rerank-2-5)",
"[Morph Rerank](https://continue.dev/morphllm/morph-rerank-v2)",
],
notes: "Open models are beginning to emerge for this model role",
},
};
function parseMarkdownLinks(text: string) {
const regex = /\[([^\]]+)\]\(([^)]+)\)/g;
const parts: React.ReactNode[] = [];
let lastIndex = 0;
let match;
let key = 0;
while ((match = regex.exec(text)) !== null) {
if (match.index > lastIndex) {
parts.push(<span key={key++}>{text.slice(lastIndex, match.index)}</span>);
}
parts.push(
<a
key={key++}
href={match[2]}
target="_blank"
rel="noopener noreferrer"
className="text-blue-600 underline"
>
{match[1]}
</a>,
);
lastIndex = regex.lastIndex;
}
if (lastIndex < text.length) {
parts.push(<span key={key++}>{text.slice(lastIndex)}</span>);
}
return parts.length > 0 ? parts : text;
}
export function ModelRecommendations({ role = "all" }: { role?: string }) {
let rolesToShow: string[];
if (!role || role === "all") {
rolesToShow = Object.keys(modelRecs);
} else {
const key = role.toLowerCase().replace(/[\s/]/g, "_").replace(/-/g, "_");
rolesToShow = modelRecs[key] ? [key] : [];
}
if (rolesToShow.length === 0) {
return <div>No recommendations found for role: {role}</div>;
}
return (
<div className="my-4 overflow-x-auto">
<table>
<thead>
<tr>
<th>Model role</th>
<th>Best open models</th>
<th>Best closed models</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
{rolesToShow.map((roleKey) => {
const rec = modelRecs[roleKey];
if (!rec) return null;
return (
<tr key={roleKey}>
<td className="font-semibold">
{roleKey
.replace(/_/g, " ")
.replace(/\b\w/g, (l) => l.toUpperCase())}
</td>
<td>
{rec.open.map((m, i) => (
<div key={i} className="mb-1">
{parseMarkdownLinks(m)}
</div>
))}
</td>
<td>
{rec.closed.map((m, i) => (
<div key={i} className="mb-1">
{parseMarkdownLinks(m)}
</div>
))}
</td>
<td>{rec.notes}</td>
</tr>
);
})}
</tbody>
</table>
</div>
);
}

View file

@ -0,0 +1,25 @@
"use client";
import { useEffect } from "react";
export function OSAutoDetect() {
useEffect(() => {
const ua = navigator.userAgent.toLowerCase();
const isWindows = ua.includes("win");
const isMac = ua.includes("mac");
const isLinux = ua.includes("linux");
let tabIndex = 2; // default: npm
if (isMac || isLinux) tabIndex = 0;
else if (isWindows) tabIndex = 1;
const tabButtons = document.querySelectorAll(
'[role="tablist"] button',
);
if (tabButtons[tabIndex]) {
(tabButtons[tabIndex] as HTMLButtonElement).click();
}
}, []);
return null;
}

View file

@ -0,0 +1,55 @@
import React from "react";
export function Steps({ children }: { children: React.ReactNode }) {
const childArray = React.Children.toArray(children).filter(
React.isValidElement,
);
return (
<div className="my-6">
{childArray.map((child, index) =>
React.cloneElement(child as React.ReactElement<any>, {
stepNumber: index + 1,
isLast: index === childArray.length - 1,
}),
)}
</div>
);
}
export function Step({
title,
stepNumber,
isLast,
children,
}: {
title?: string;
stepNumber?: number;
isLast?: boolean;
children: React.ReactNode;
}) {
return (
<div className="relative pl-10">
{/* Numbered circle */}
<div className="absolute left-0 top-0.5 flex h-7 w-7 items-center justify-center rounded-full bg-black/[0.08] dark:bg-white/[0.1]">
<span className="text-xs font-medium text-black/70 dark:text-white/70">
{stepNumber}
</span>
</div>
{/* Connecting line */}
{!isLast && (
<div className="absolute bottom-0 left-[13px] top-8 w-[2px] bg-black/[0.08] dark:bg-white/[0.08]" />
)}
{/* Content */}
<div className={isLast ? "" : "pb-8"}>
{title && (
<h3 className="!mt-0 mb-2 text-[15px] font-semibold text-black/80 dark:text-white/80">
{title}
</h3>
)}
<div className="text-sm text-black/60 dark:text-white/60 [&>p:last-child]:mb-0">
{children}
</div>
</div>
</div>
);
}

View file

@ -0,0 +1,70 @@
import type { MDXComponents } from "mdx/types";
import { Callout } from "./Callout";
import { CardGroup, Card } from "./CardGroup";
import { Steps, Step } from "./Steps";
import { DocsTabs, DocsTab } from "./DocsTabs";
import { DocsAccordion, DocsAccordionGroup } from "./DocsAccordion";
import { Columns } from "./Columns";
import { ModelRecommendations } from "./ModelRecommendations";
import { OSAutoDetect } from "./OSAutoDetect";
import { CodeBlock } from "./CodeBlock";
import { CodeGroup } from "./CodeGroup";
import { MdxLink } from "./MdxLink";
export const mdxComponents: MDXComponents = {
// Mintlify callout variants
Info: (props: any) => <Callout variant="info" {...props} />,
Tip: (props: any) => <Callout variant="tip" {...props} />,
Warning: (props: any) => <Callout variant="warning" {...props} />,
Note: (props: any) => <Callout variant="note" {...props} />,
Check: (props: any) => <Callout variant="tip" {...props} />,
Danger: (props: any) => <Callout variant="warning" {...props} />,
Callout,
// Cards
Card,
CardGroup,
// Steps
Steps,
Step,
// Tabs
Tabs: DocsTabs,
Tab: DocsTab,
// Accordion
Accordion: DocsAccordion,
AccordionGroup: DocsAccordionGroup,
// Layout
Columns,
Frame: ({ children, ...props }: any) => (
<div className="my-4" {...props}>
{children}
</div>
),
// Custom snippets
ModelRecommendations,
OSAutoDetect,
// Code blocks
pre: (props: any) => <CodeBlock {...props} />,
CodeGroup,
// Use div instead of p to avoid hydration errors when MDX wraps
// block-level components (Callout, Card, etc.) in paragraph tags.
p: (props: any) => <div className="docs-p" {...props} />,
// Rewrite internal doc links to include /docs prefix and resolve subdomain URLs
a: MdxLink,
// Rewrite image paths — images are copied to public/images/docs/ at build time
img: ({ src, alt, ...props }: any) => {
if (src && src.startsWith("/images/")) {
src = `/images/docs${src.slice("/images".length)}`;
}
return <img src={src} alt={alt || ""} {...props} />;
},
};

View file

@ -0,0 +1,161 @@
"use client";
import { type DialogProps } from "@radix-ui/react-dialog";
import { Command as CommandPrimitive } from "cmdk";
import { Search } from "lucide-react";
import * as React from "react";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
import { cn } from "@/lib/utils";
const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
>(({ className, ...props }, ref) => (
<CommandPrimitive
ref={ref}
className={cn(
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
className,
)}
{...props}
/>
));
Command.displayName = CommandPrimitive.displayName;
interface CommandDialogProps extends DialogProps {
dialogClassName?: string;
}
const CommandDialog = ({ children, dialogClassName, ...props }: CommandDialogProps) => {
return (
<Dialog {...props}>
<DialogContent className={cn("overflow-hidden p-0 shadow-lg", dialogClassName)}>
<VisuallyHidden>
<DialogTitle>Search</DialogTitle>
</VisuallyHidden>
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
{children}
</Command>
</DialogContent>
</Dialog>
);
};
const CommandInput = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Input>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
>(({ className, ...props }, ref) => (
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
<CommandPrimitive.Input
ref={ref}
className={cn(
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
{...props}
/>
</div>
));
CommandInput.displayName = CommandPrimitive.Input.displayName;
const CommandList = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.List>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
>(({ className, ...props }, ref) => (
<CommandPrimitive.List
ref={ref}
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
{...props}
/>
));
CommandList.displayName = CommandPrimitive.List.displayName;
const CommandEmpty = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Empty>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
>((props, ref) => (
<CommandPrimitive.Empty
ref={ref}
className="py-6 text-center text-sm"
{...props}
/>
));
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
const CommandGroup = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Group>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Group
ref={ref}
className={cn(
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
className,
)}
{...props}
/>
));
CommandGroup.displayName = CommandPrimitive.Group.displayName;
const CommandSeparator = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Separator
ref={ref}
className={cn("-mx-1 h-px bg-border", className)}
{...props}
/>
));
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
const CommandItem = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
className,
)}
{...props}
/>
));
CommandItem.displayName = CommandPrimitive.Item.displayName;
const CommandShortcut = ({
className,
...props
}: React.HTMLAttributes<HTMLSpanElement>) => {
return (
<span
className={cn(
"ml-auto text-xs tracking-widest text-muted-foreground",
className,
)}
{...props}
/>
);
};
CommandShortcut.displayName = "CommandShortcut";
export {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
};

View file

@ -0,0 +1,123 @@
"use client";
import * as React from "react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { X } from "lucide-react";
import { cn } from "@/lib/utils";
const Dialog = DialogPrimitive.Root;
const DialogTrigger = DialogPrimitive.Trigger;
const DialogPortal = DialogPrimitive.Portal;
const DialogClose = DialogPrimitive.Close;
const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className,
)}
{...props}
/>
));
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay className="overflow-y-auto flex items-center justify-center p-4">
<DialogPrimitive.Content
ref={ref}
className={cn(
"relative z-50 my-auto grid w-full max-w-lg gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
className,
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogOverlay>
</DialogPortal>
));
DialogContent.displayName = DialogPrimitive.Content.displayName;
const DialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-1.5 text-center sm:text-left",
className,
)}
{...props}
/>
);
DialogHeader.displayName = "DialogHeader";
const DialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className,
)}
{...props}
/>
);
DialogFooter.displayName = "DialogFooter";
const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className,
)}
{...props}
/>
));
DialogTitle.displayName = DialogPrimitive.Title.displayName;
const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
DialogDescription.displayName = DialogPrimitive.Description.displayName;
export {
Dialog,
DialogPortal,
DialogOverlay,
DialogClose,
DialogTrigger,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription,
};

View file

@ -0,0 +1,72 @@
// Navigation types and pure helpers for docs sidebar.
// Data loading happens server-side in lib/docs.ts — these are safe for client components.
export type NavItem = string | NavGroup;
export interface NavGroup {
group: string;
icon?: string;
expanded?: boolean;
pages: NavItem[];
}
export interface NavTab {
tab: string;
groups: NavGroup[];
}
// Flatten all page slugs in order for prev/next navigation
function flattenPages(items: NavItem[]): string[] {
const result: string[] = [];
for (const item of items) {
if (typeof item === "string") {
result.push(item);
} else {
result.push(...flattenPages(item.pages));
}
}
return result;
}
function getAllPagesFlat(nav: NavTab[]): string[] {
const all: string[] = [];
for (const tab of nav) {
for (const group of tab.groups) {
all.push(...flattenPages(group.pages));
}
}
// Deduplicate while preserving order
return Array.from(new Set(all));
}
function slugToTitle(slug: string): string {
const name = slug.split("/").pop() || slug;
return name
.replace(/^\d+-/, "")
.replace(/-/g, " ")
.replace(/\b\w/g, (l) => l.toUpperCase());
}
export function getPageNavigation(
nav: NavTab[],
currentSlug: string,
titleMap?: Record<string, string>,
): {
prev: { slug: string; title: string } | null;
next: { slug: string; title: string } | null;
} {
const pages = getAllPagesFlat(nav);
const idx = pages.indexOf(currentSlug);
if (idx === -1) return { prev: null, next: null };
const prevSlug = idx > 0 ? pages[idx - 1] : undefined;
const nextSlug = idx < pages.length - 1 ? pages[idx + 1] : undefined;
const getTitle = (slug: string) => titleMap?.[slug] || slugToTitle(slug);
const prev = prevSlug ? { slug: prevSlug, title: getTitle(prevSlug) } : null;
const next = nextSlug ? { slug: nextSlug, title: getTitle(nextSlug) } : null;
return { prev, next };
}

296
docs-site/lib/docs.ts Normal file
View file

@ -0,0 +1,296 @@
import fs from "fs";
import path from "path";
import matter from "gray-matter";
import { type NavItem, type NavTab } from "@/config/docsNav";
const DOCS_DIR =
process.env.DOCS_DIR || path.resolve(process.cwd(), "../docs");
export function getDocsDir() {
return DOCS_DIR;
}
export function loadDocsNav(): NavTab[] {
const docsJsonPath = path.join(DOCS_DIR, "docs.json");
if (!fs.existsSync(docsJsonPath)) {
console.warn(`docs.json not found at ${docsJsonPath}, using empty nav`);
return [];
}
const raw = JSON.parse(fs.readFileSync(docsJsonPath, "utf8"));
return raw.navigation?.tabs ?? [];
}
export const docsNav: NavTab[] = loadDocsNav();
function loadDocsRedirects(): Map<string, string> {
const docsJsonPath = path.join(DOCS_DIR, "docs.json");
if (!fs.existsSync(docsJsonPath)) return new Map();
const raw = JSON.parse(fs.readFileSync(docsJsonPath, "utf8"));
const redirects = new Map<string, string>();
for (const entry of raw.redirects ?? []) {
const source = (entry.source as string).replace(/^\//, "");
redirects.set(source, entry.destination as string);
}
return redirects;
}
export const docsRedirects: Map<string, string> = loadDocsRedirects();
// Whitelist of allowed external redirect domains for security
const ALLOWED_REDIRECT_DOMAINS = [
"continue.dev",
"docs.continue.dev",
"www.continue.dev",
"changelog.continue.dev",
];
export function resolveDocsRedirect(slug: string[]): string | null {
const key = slug.join("/");
const dest = docsRedirects.get(key);
if (!dest) return null;
// Handle external URLs
if (dest.startsWith("https://") || dest.startsWith("http://")) {
try {
const url = new URL(dest);
// Only allow redirects to whitelisted domains
if (!ALLOWED_REDIRECT_DOMAINS.includes(url.hostname)) {
console.warn(`Blocked redirect to untrusted domain: ${url.hostname}`);
return null;
}
return dest;
} catch {
console.warn(`Invalid redirect URL: ${dest}`);
return null;
}
}
// Internal redirects - ensure they start with /
return dest.startsWith("/") ? dest : `/${dest}`;
}
export interface DocFile {
frontmatter: Record<string, any>;
content: string;
slug: string[];
}
export async function loadMdxFile(
slug: string[],
): Promise<DocFile | null> {
const slugPath = slug.join("/");
const filePath = path.join(DOCS_DIR, slugPath + ".mdx");
if (fs.existsSync(filePath)) {
return readDocFile(filePath, slug);
}
// Try index.mdx inside directory
const indexPath = path.join(DOCS_DIR, slugPath, "index.mdx");
if (fs.existsSync(indexPath)) {
return readDocFile(indexPath, slug);
}
return null;
}
export async function loadRawMdxFile(
slug: string[],
): Promise<{ raw: string; fileName: string } | null> {
const slugPath = slug.join("/");
const filePath = path.join(DOCS_DIR, slugPath + ".mdx");
// Prevent path traversal — ensure the resolved path stays inside DOCS_DIR.
const docsDirNormalized = DOCS_DIR.endsWith(path.sep) ? DOCS_DIR : DOCS_DIR + path.sep;
const isWithinDocsDir = (p: string) => p.startsWith(docsDirNormalized);
if (isWithinDocsDir(filePath) && fs.existsSync(filePath)) {
return {
raw: fs.readFileSync(filePath, "utf8"),
fileName: slug[slug.length - 1] + ".md",
};
}
const indexPath = path.join(DOCS_DIR, slugPath, "index.mdx");
if (isWithinDocsDir(indexPath) && fs.existsSync(indexPath)) {
return {
raw: fs.readFileSync(indexPath, "utf8"),
fileName: slug[slug.length - 1] + ".md",
};
}
return null;
}
function readDocFile(filePath: string, slug: string[]): DocFile {
const raw = fs.readFileSync(filePath, "utf8");
const { data: frontmatter, content } = matter(raw);
const processed = preprocessMdx(content, slug);
return { frontmatter, content: processed, slug };
}
/**
* Preprocess MDX content:
* 1. Find MDX snippet imports (import X from '/snippets/foo.mdx')
* 2. Inline the snippet content in place of <X /> usage
* 3. Strip JSX component imports (handled via components map)
*/
function preprocessMdx(content: string, slug: string[]): string {
// Collect MDX snippet imports: import Name from '/snippets/file.mdx'
const mdxImportRegex =
/^import\s+(\w+)\s+from\s+['"]\/snippets\/([^'"]+\.mdx)['"];?\s*$/gm;
const snippets = new Map<string, string>();
let match;
while ((match = mdxImportRegex.exec(content)) !== null) {
const componentName = match[1]!;
const snippetFile = match[2]!;
const snippetPath = path.join(DOCS_DIR, "snippets", snippetFile);
if (fs.existsSync(snippetPath)) {
const snippetRaw = fs.readFileSync(snippetPath, "utf8");
const { content: snippetContent } = matter(snippetRaw);
snippets.set(componentName, snippetContent.trim());
}
}
let result = content;
// Replace <SnippetName /> with inlined content
for (const [name, body] of Array.from(snippets.entries())) {
const selfClosing = new RegExp(`<${name}\\s*/>`, "g");
const withChildren = new RegExp(
`<${name}\\s*>[\\s\\S]*?</${name}>`,
"g",
);
result = result.replace(selfClosing, body);
result = result.replace(withChildren, body);
}
// Strip all remaining import statements (JSX snippets handled via components map)
result = result.replace(
/^import\s+.*from\s+['"].*['"];?\s*$/gm,
"",
);
// Convert :::warning / :::info / :::tip admonitions to JSX components
result = result.replace(
/^:::(warning|info|tip|note|danger)\s*\n([\s\S]*?)^:::\s*$/gm,
(_match, type: string, body: string) => {
const tag = type.charAt(0).toUpperCase() + type.slice(1);
return `<${tag}>${body.trim()}</${tag}>`;
},
);
// Ensure --- horizontal rules have blank lines before them
// (prevents Setext h2 interpretation when preceded by text)
// Only apply outside of fenced code blocks.
result = result.replace(
/(```[\s\S]*?```)|([^\n])\n---\n/g,
(match, codeBlock, prev) => {
if (codeBlock) return codeBlock; // leave code blocks untouched
return `${prev}\n\n---\n`;
},
);
// Rewrite image paths: /images/... → /images/docs/...
result = result.replace(
/src=["']\/images\//g,
'src="/images/docs/',
);
// Rewrite markdown image paths: ![alt](/images/...) → ![alt](/images/docs/...)
result = result.replace(
/\]\(\/images\//g,
"](/images/docs/",
);
// Rewrite relative image paths: ![alt](../images/...) → ![alt](/images/docs/...)
// Resolve relative to the current file's directory
const fileDir = slug.slice(0, -1).join("/");
result = result.replace(
/\]\((\.\.?\/[^)]*\.(png|jpg|jpeg|gif|svg|webp))\)/gi,
(_match, relPath: string) => {
const resolved = path.posix.normalize(
fileDir ? `${fileDir}/${relPath}` : relPath,
);
return `](/images/docs/${resolved})`;
},
);
return result;
}
export interface Heading {
level: number;
text: string;
id: string;
}
export function getHeadings(content: string): Heading[] {
const regex = /^(#{2,4})\s+(.+)$/gm;
const headings: Heading[] = [];
let match;
while ((match = regex.exec(content)) !== null) {
const level = match[1]!.length;
const text = match[2]!.trim();
const id = text
.toLowerCase()
.replace(/[^\w\s-]/g, "")
.replace(/\s+/g, "-");
headings.push({ level, text, id });
}
return headings;
}
export function getAllDocSlugs(): string[] {
const slugs: string[] = [];
function walk(items: NavItem[]) {
for (const item of items) {
if (typeof item === "string") slugs.push(item);
else if (item.pages) walk(item.pages);
}
}
for (const tab of docsNav) {
for (const group of tab.groups) {
walk(group.pages);
}
}
return Array.from(new Set(slugs));
}
/**
* Build a map of slug → display title by reading frontmatter from all docs.
* Prefers sidebarTitle over title, falls back to slug-derived name.
*/
export function getAllDocTitles(): Record<string, string> {
const slugs = getAllDocSlugs();
const titles: Record<string, string> = {};
for (const slug of slugs) {
const slugPath = slug;
const filePath = path.join(DOCS_DIR, slugPath + ".mdx");
const indexPath = path.join(DOCS_DIR, slugPath, "index.mdx");
let resolved: string | null = null;
if (fs.existsSync(filePath)) resolved = filePath;
else if (fs.existsSync(indexPath)) resolved = indexPath;
if (resolved) {
const raw = fs.readFileSync(resolved, "utf8");
const { data } = matter(raw);
const title = data.sidebarTitle || data.title;
if (title) {
titles[slug] = title;
}
}
}
return titles;
}

View file

@ -0,0 +1,19 @@
/**
* Resolve internal paths for the standalone docs app.
*
* On the docs subdomain, /docs/X becomes /X (we're already on docs.continue.dev).
* Cross-app links get absolute URLs.
*/
export function resolveHref(path: string): string {
// Strip /docs prefix — we're already on the docs domain
if (path.startsWith("/docs/")) return path.slice(5);
if (path === "/docs") return "/";
// Cross-app links → absolute URLs
if (path.startsWith("/blog")) return `https://blog.continue.dev${path.slice(5) || ""}`;
if (path === "/login") return "https://continue.dev/login";
if (path === "/") return "https://continue.dev";
// Everything else stays as-is
return path;
}

6
docs-site/lib/utils.ts Normal file
View file

@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

6
docs-site/next-env.d.ts vendored Normal file
View file

@ -0,0 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

12
docs-site/next.config.js Normal file
View file

@ -0,0 +1,12 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
typescript: {
ignoreBuildErrors: true,
},
images: {
unoptimized: true,
},
};
module.exports = nextConfig;

6041
docs-site/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

50
docs-site/package.json Normal file
View file

@ -0,0 +1,50 @@
{
"name": "continue-docs",
"version": "0.1.0",
"private": true,
"scripts": {
"prebuild": "npx tsx scripts/copy-doc-images.ts && npx tsx scripts/build-search-index.ts",
"dev": "npx tsx scripts/copy-doc-images.ts && npx tsx scripts/build-search-index.ts && next dev -p 3005",
"build": "next build",
"start": "next start -p 3005",
"lint": "next lint",
"tsc:check": "tsc --noEmit",
"tsc:watch": "tsc --watch --noEmit --pretty"
},
"dependencies": {
"@orama/orama": "^3.0.0",
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-dialog": "^1.1.6",
"@radix-ui/react-tabs": "^1.1.0",
"@radix-ui/react-visually-hidden": "^1.1.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "1.0.4",
"geist": "^1.3.1",
"gray-matter": "^4.0.3",
"lucide-react": "^0.414.0",
"next": "^16.1.1",
"next-mdx-remote": "^6.0.0",
"next-themes": "^0.4.4",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"rehype-autolink-headings": "^7.1.0",
"rehype-prism-plus": "^2.0.1",
"rehype-raw": "^7.0.0",
"rehype-sanitize": "^6.0.0",
"rehype-slug": "^6.0.0",
"remark-gfm": "^4.0.1",
"tailwind-merge": "^2.6.0"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.19",
"@types/node": "^20",
"@types/react": "19.2.8",
"@types/react-dom": "19.2.3",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.5",
"tsx": "^4.0.0",
"typescript": "^5"
}
}

View file

@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View file

@ -0,0 +1,107 @@
/**
* Build-time script that generates the Orama search index as a static JSON file.
* Run via: npx tsx scripts/build-search-index.ts
*/
import fs from "fs";
import path from "path";
import matter from "gray-matter";
import { create, insert, save } from "@orama/orama";
const DOCS_DIR = path.resolve(__dirname, "../../docs");
function loadDocsNav() {
const docsJsonPath = path.join(DOCS_DIR, "docs.json");
if (!fs.existsSync(docsJsonPath)) return [];
const raw = JSON.parse(fs.readFileSync(docsJsonPath, "utf8"));
return raw.navigation?.tabs ?? [];
}
function getAllDocSlugs(nav: any[]): string[] {
const slugs: string[] = [];
function walk(items: any[]) {
for (const item of items) {
if (typeof item === "string") slugs.push(item);
else if (item.pages) walk(item.pages);
}
}
for (const tab of nav) {
for (const group of tab.groups) {
walk(group.pages);
}
}
return Array.from(new Set(slugs));
}
function stripMdx(content: string): string {
return content
.replace(/<[^>]+>/g, "")
.replace(/```[\s\S]*?```/g, "")
.replace(/`[^`]+`/g, "")
.replace(/!\[.*?\]\(.*?\)/g, "")
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
.replace(/^#+\s+/gm, "")
.replace(/\*\*([^*]+)\*\*/g, "$1")
.replace(/\*([^*]+)\*/g, "$1")
.replace(/\n{3,}/g, "\n\n")
.trim();
}
function loadMdxFile(slug: string) {
const filePath = path.join(DOCS_DIR, slug + ".mdx");
if (fs.existsSync(filePath)) {
const raw = fs.readFileSync(filePath, "utf8");
const { data, content } = matter(raw);
return { frontmatter: data, content };
}
const indexPath = path.join(DOCS_DIR, slug, "index.mdx");
if (fs.existsSync(indexPath)) {
const raw = fs.readFileSync(indexPath, "utf8");
const { data, content } = matter(raw);
return { frontmatter: data, content };
}
return null;
}
async function main() {
const nav = loadDocsNav();
const slugs = getAllDocSlugs(nav);
const db = create({
schema: {
title: "string" as const,
path: "string" as const,
content: "string" as const,
section: "string" as const,
},
});
for (const slug of slugs) {
const doc = loadMdxFile(slug);
if (!doc) continue;
const title =
doc.frontmatter.title ||
slug
.split("/")
.pop()!
.replace(/^\d+-/, "")
.replace(/-/g, " ")
.replace(/\b\w/g, (l: string) => l.toUpperCase());
const section = slug.split("/")[0] || "docs";
const plainText = stripMdx(doc.content);
insert(db, { title, path: slug, content: plainText, section });
}
const data = save(db);
const outDir = path.resolve(__dirname, "../public");
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
fs.writeFileSync(path.join(outDir, "search-index.json"), JSON.stringify(data));
console.log(`Search index written to public/search-index.json (${slugs.length} docs)`);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});

View file

@ -0,0 +1,62 @@
/**
* Build-time script that copies images from the docs directory to public/images/docs/.
* Run via: npx tsx scripts/copy-doc-images.ts
*/
import fs from "fs";
import path from "path";
const DOCS_DIR = path.resolve(__dirname, "../../docs");
const OUT_DIR = path.resolve(__dirname, "../public/images/docs");
const IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".gif", ".svg", ".webp", ".ico"]);
function copyImagesRecursive(srcDir: string, destDir: string) {
if (!fs.existsSync(srcDir)) return;
const entries = fs.readdirSync(srcDir, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(srcDir, entry.name);
const destPath = path.join(destDir, entry.name);
if (entry.isDirectory()) {
copyImagesRecursive(srcPath, destPath);
} else if (IMAGE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) {
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
fs.copyFileSync(srcPath, destPath);
}
}
}
function main() {
// Clean output directory
if (fs.existsSync(OUT_DIR)) {
fs.rmSync(OUT_DIR, { recursive: true });
}
// Copy all images from docs/images/ to public/images/docs/
const imagesDir = path.join(DOCS_DIR, "images");
if (fs.existsSync(imagesDir)) {
copyImagesRecursive(imagesDir, OUT_DIR);
}
// Also copy any images scattered in other doc subdirectories
// (for relative image references like ../some-dir/image.png)
copyImagesRecursive(DOCS_DIR, OUT_DIR);
// Count copied files
let count = 0;
function countFiles(dir: string) {
if (!fs.existsSync(dir)) return;
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
if (entry.isDirectory()) countFiles(path.join(dir, entry.name));
else count++;
}
}
countFiles(OUT_DIR);
console.log(`Copied ${count} images to public/images/docs/`);
}
main();

View file

@ -0,0 +1,14 @@
import type { Config } from "tailwindcss";
const config: Config = {
darkMode: "class",
content: [
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {},
},
plugins: [],
};
export default config;

41
docs-site/tsconfig.json Normal file
View file

@ -0,0 +1,41 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}