Merge pull request #4 from continuedev/nate/cleanup
THX: Eliminate free trial, migrate docs site, document secrets
This commit is contained in:
commit
49b7de09ac
49 changed files with 9234 additions and 15 deletions
55
.github/workflows/docs-gh-pages.yml
vendored
Normal file
55
.github/workflows/docs-gh-pages.yml
vendored
Normal 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
1
.gitignore
vendored
|
|
@ -15,6 +15,7 @@ downloads/
|
|||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
!docs-site/lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
|
|
|
|||
105
BUILD_DEPENDENCIES.md
Normal file
105
BUILD_DEPENDENCIES.md
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
# Build Dependencies & Secrets
|
||||
|
||||
This document catalogs all build dependencies, secrets, and environment variables required by the continue-fork repository.
|
||||
|
||||
---
|
||||
|
||||
## VS Code Extension
|
||||
|
||||
| Secret | Purpose | Referenced In |
|
||||
| -------------------- | ----------------------------------------------------------------------------------- | --------------------------- |
|
||||
| `VSCE_TOKEN` | Personal access token for publishing to the VS Code Marketplace (set as `VSCE_PAT`) | `main.yaml`, `preview.yaml` |
|
||||
| `VSX_REGISTRY_TOKEN` | Token for publishing to the Open VSX Registry | `main.yaml`, `preview.yaml` |
|
||||
|
||||
---
|
||||
|
||||
## JetBrains Extension
|
||||
|
||||
| Secret | Purpose | Referenced In |
|
||||
| -------------------------------- | --------------------------------------------------------------------- | ------------------------ |
|
||||
| `APPLE_CERT_DATA` | Base64-encoded Apple signing certificate (p12) for macOS code signing | `jetbrains-release.yaml` |
|
||||
| `APPLE_CERT_PASSWORD` | Password for the Apple signing certificate | `jetbrains-release.yaml` |
|
||||
| `APPLE_NOTARY_USER` | Apple notarization username (currently commented out) | `jetbrains-release.yaml` |
|
||||
| `APPLE_NOTARY_PASSWORD` | Apple notarization password (currently commented out) | `jetbrains-release.yaml` |
|
||||
| `JETBRAINS_PUBLISH_TOKEN` | Token for publishing to JetBrains Marketplace | `jetbrains-release.yaml` |
|
||||
| `JETBRAINS_CERTIFICATE_CHAIN` | Certificate chain for signing the JetBrains plugin | `jetbrains-release.yaml` |
|
||||
| `JETBRAINS_PRIVATE_KEY` | Private key for signing the JetBrains plugin | `jetbrains-release.yaml` |
|
||||
| `JETBRAINS_PRIVATE_KEY_PASSWORD` | Password for the JetBrains signing private key | `jetbrains-release.yaml` |
|
||||
|
||||
---
|
||||
|
||||
## CLI
|
||||
|
||||
| Variable | Purpose | Referenced In |
|
||||
| ------------------- | ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
||||
| `CONTINUE_API_BASE` | Base URL for the Continue API (defaults to `https://api.continue.dev/`) | `extensions/cli/.env.example` |
|
||||
| `CONTINUE_API_KEY` | API key for Continue authentication | `extensions/cli/.env.example`, `packages/continue-sdk/typescript/.env.example`, multiple workflows |
|
||||
|
||||
---
|
||||
|
||||
## NPM Package Releases
|
||||
|
||||
| Secret | Purpose | Referenced In |
|
||||
| ------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `SEMANTIC_RELEASE_GITHUB_TOKEN` | GitHub token used by semantic-release for creating releases | `release-openai-adapters.yml`, `release-config-yaml.yml`, `release-fetch.yml`, `release-llm-info.yml`, `reusable-release.yml` |
|
||||
| `SEMANTIC_RELEASE_NPM_TOKEN` | npm token used by semantic-release for publishing packages | `release-openai-adapters.yml`, `release-config-yaml.yml`, `release-fetch.yml`, `release-llm-info.yml`, `reusable-release.yml` |
|
||||
| `SEMANTIC_RELEASE_TOKEN` | GitHub token for stable release workflow | `stable-release.yml` |
|
||||
|
||||
---
|
||||
|
||||
## AI Provider API Keys (Testing & Releases)
|
||||
|
||||
Used for integration tests in PR checks and package releases.
|
||||
|
||||
| Secret | Purpose | Referenced In |
|
||||
| ------------------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
||||
| `OPENAI_API_KEY` | OpenAI API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `ANTHROPIC_API_KEY` | Anthropic API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml`, `cli-pr-checks.yml`, `continue-agents.yml` |
|
||||
| `GEMINI_API_KEY` | Google Gemini API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `MISTRAL_API_KEY` | Mistral API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `AZURE_OPENAI_API_KEY` | Azure OpenAI API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `AZURE_FOUNDRY_CODESTRAL_API_KEY` | Azure AI Foundry Codestral API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY` | Azure AI Foundry Mistral Small API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `AZURE_OPENAI_GPT41_API_KEY` | Azure OpenAI GPT-4.1 API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `VOYAGE_API_KEY` | Voyage AI embeddings API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `RELACE_API_KEY` | Relace API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
| `INCEPTION_API_KEY` | Inception API key | `pr-checks.yaml`, `reusable-release.yml`, `release-*.yml` |
|
||||
|
||||
---
|
||||
|
||||
## CI/CD & GitHub
|
||||
|
||||
| Secret | Purpose | Referenced In |
|
||||
| ------------------ | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| `GITHUB_TOKEN` | Default GitHub Actions token (automatic) | Many workflows |
|
||||
| `CI_GITHUB_TOKEN` | Elevated GitHub PAT for cross-repo operations and PR management | `jetbrains-release.yaml`, `preview.yaml`, `main.yaml`, `pr-checks.yaml`, `auto-assign-issue.yaml` |
|
||||
| `CONTINUE_API_KEY` | Continue platform API key for agent workflows | `run-continue-agent.yml`, `tidy-up-codebase.yml`, `snyk-agent.yaml`, `auto-fix-failed-tests.yml`, `cli-pr-checks.yml` |
|
||||
| `RUNLOOP_API_KEY` | Runloop API key for uploading sandbox blueprints | `stable-release.yml`, `upload-runloop-blueprint.yml` |
|
||||
| `SNYK_TOKEN` | Snyk security scanning token | `snyk-agent.yaml` |
|
||||
|
||||
---
|
||||
|
||||
## Issue/PR Tooling
|
||||
|
||||
| Secret | Purpose | Referenced In |
|
||||
| ------------------------------------ | ---------------------------------------------------- | -------------------- |
|
||||
| `CHROMA_CLOUD_API_KEY` | Chroma vector DB API key for similar issue detection | `similar-issues.yml` |
|
||||
| `CHROMA_TENANT` | Chroma tenant identifier | `similar-issues.yml` |
|
||||
| `CHROMA_DATABASE` | Chroma database name | `similar-issues.yml` |
|
||||
| `ISSUE_PR_METRICS_SLACK_WEBHOOK_URL` | Slack webhook for PR/issue metrics notifications | `metrics.yaml` |
|
||||
|
||||
---
|
||||
|
||||
## SSH Testing
|
||||
|
||||
| Secret | Purpose | Referenced In |
|
||||
| ------------------------------ | ------------------------------------------- | ---------------- |
|
||||
| `GH_ACTIONS_SSH_TEST_KEY_PEM` | SSH private key for remote connection tests | `pr-checks.yaml` |
|
||||
| `GH_ACTIONS_SSH_TEST_DNS_NAME` | DNS name of the SSH test host | `pr-checks.yaml` |
|
||||
|
||||
---
|
||||
|
||||
All workflow files are located under `.github/workflows/`. Environment example files are at:
|
||||
|
||||
- `extensions/cli/.env.example`
|
||||
- `packages/continue-sdk/typescript/.env.example`
|
||||
|
|
@ -62,13 +62,9 @@ describe("LocalProfileLoader", () => {
|
|||
configName: "My Custom Config",
|
||||
});
|
||||
|
||||
const loader = new LocalProfileLoader(
|
||||
testIde,
|
||||
controlPlaneClient,
|
||||
llmLogger,
|
||||
);
|
||||
const loader = new LocalProfileLoader(testIde, llmLogger);
|
||||
|
||||
expect(loader.description.title).toBe("Local Config");
|
||||
expect(loader.description.title).toBe("Main Config");
|
||||
|
||||
await loader.doLoadConfig();
|
||||
|
||||
|
|
@ -82,14 +78,10 @@ describe("LocalProfileLoader", () => {
|
|||
configLoadInterrupted: false,
|
||||
});
|
||||
|
||||
const loader = new LocalProfileLoader(
|
||||
testIde,
|
||||
controlPlaneClient,
|
||||
llmLogger,
|
||||
);
|
||||
const loader = new LocalProfileLoader(testIde, llmLogger);
|
||||
|
||||
await loader.doLoadConfig();
|
||||
|
||||
expect(loader.description.title).toBe("Local Config");
|
||||
expect(loader.description.title).toBe("Main Config");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
5
docs-site/.gitignore
vendored
Normal file
5
docs-site/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
.next/
|
||||
out/
|
||||
node_modules/
|
||||
public/search-index.json
|
||||
public/images/docs/
|
||||
133
docs-site/app/[[...slug]]/page.tsx
Normal file
133
docs-site/app/[[...slug]]/page.tsx
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
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="mb-2 flex items-start justify-between gap-4">
|
||||
<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="mb-8 text-lg text-black/50 dark:text-white/50">
|
||||
{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>
|
||||
);
|
||||
}
|
||||
15
docs-site/app/components/ClientRedirect.tsx
Normal file
15
docs-site/app/components/ClientRedirect.tsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
export function ClientRedirect({ to }: { to: string }) {
|
||||
useEffect(() => {
|
||||
window.location.replace(to);
|
||||
}, [to]);
|
||||
|
||||
return (
|
||||
<div className="flex min-h-[60vh] items-center justify-center">
|
||||
<p className="text-sm text-black/40 dark:text-white/40">Redirecting...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
17
docs-site/app/components/NotFoundPage.tsx
Normal file
17
docs-site/app/components/NotFoundPage.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import Link from "next/link";
|
||||
|
||||
export default function NotFoundPage() {
|
||||
return (
|
||||
<div className="flex min-h-[60vh] flex-col items-center justify-center 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 hover:text-black/70 dark:text-white/40 dark:hover:text-white/70"
|
||||
>
|
||||
Back to docs
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
336
docs-site/app/docs.css
Normal file
336
docs-site/app/docs.css
Normal 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;
|
||||
}
|
||||
3
docs-site/app/globals.css
Normal file
3
docs-site/app/globals.css
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
43
docs-site/app/layout.tsx
Normal file
43
docs-site/app/layout.tsx
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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>
|
||||
);
|
||||
}
|
||||
28
docs-site/components/docs/CopyPageButton.tsx
Normal file
28
docs-site/components/docs/CopyPageButton.tsx
Normal 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 whitespace-nowrap rounded-md px-2 py-1 text-[13px] text-black/35 transition-colors hover:bg-black/[0.04] hover:text-black/60 dark:text-white/35 dark:hover:bg-white/[0.04] dark:hover:text-white/60"
|
||||
>
|
||||
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
|
||||
<span>{copied ? "Copied" : "Copy page"}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
152
docs-site/components/docs/DocsSearch.tsx
Normal file
152
docs-site/components/docs/DocsSearch.tsx
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
"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 h-9 w-full max-w-md items-center gap-2 rounded-lg border border-black/10 bg-black/[0.02] px-3 text-[13px] text-black/40 transition-colors hover:border-black/20 dark:border-white/10 dark:bg-white/[0.04] dark:text-white/40 dark:hover:border-white/20"
|
||||
>
|
||||
<Search className="h-4 w-4 flex-shrink-0" />
|
||||
<span className="flex-1 text-left">Search...</span>
|
||||
<kbd className="hidden h-5 items-center gap-0.5 rounded border border-black/10 bg-black/[0.03] px-1.5 font-mono text-[10px] text-black/40 sm:inline-flex dark:border-white/10 dark:bg-white/[0.06] dark:text-white/40">
|
||||
<span className="text-xs">⌘</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="text-muted-foreground py-6 text-center text-sm">
|
||||
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-muted-foreground line-clamp-1 text-xs">
|
||||
{result.content.slice(0, 120)}
|
||||
</span>
|
||||
</div>
|
||||
</CommandItem>
|
||||
))}
|
||||
</CommandGroup>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</CommandList>
|
||||
</CommandDialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
417
docs-site/components/docs/DocsShell.tsx
Normal file
417
docs-site/components/docs/DocsShell.tsx
Normal file
|
|
@ -0,0 +1,417 @@
|
|||
"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="h-8 w-8" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
|
||||
className="p-2 text-black/40 transition-colors hover:text-black/70 dark:text-white/40 dark:hover:text-white/70"
|
||||
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="-mx-2.5 flex w-full items-center justify-between px-2.5 py-1.5 text-[13px] text-black/45 hover:text-black/70 dark:text-white/45 dark:hover:text-white/70"
|
||||
>
|
||||
<span>{group.group}</span>
|
||||
<ChevronDown
|
||||
className={`h-3.5 w-3.5 text-black/30 transition-transform dark:text-white/30 ${
|
||||
open ? "rotate-0" : "-rotate-90"
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
{open && (
|
||||
<div className="ml-3 space-y-0.5 border-l border-black/[0.06] pl-3 dark:border-white/[0.06]">
|
||||
{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={`-mx-2.5 block rounded px-2.5 py-1.5 text-[13px] no-underline transition-colors ${
|
||||
isActive
|
||||
? "bg-black/[0.04] font-medium text-black/90 dark:bg-white/[0.06] dark:text-white/90"
|
||||
: "text-black/45 hover:text-black/70 dark:text-white/45 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 h-full flex-col">
|
||||
{/* ---- Header: nav + tabs ---- */}
|
||||
<div className="z-30 flex-shrink-0 bg-white dark:bg-[#0a0a0a]">
|
||||
{/* Top nav bar */}
|
||||
<nav className="border-b border-black/[0.06] dark:border-white/[0.06]">
|
||||
<div className="mx-auto flex max-w-[90rem] items-center">
|
||||
{/* Logo — same width & padding as sidebar */}
|
||||
<div
|
||||
className={`hidden items-center lg:flex ${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="flex items-center px-5 py-3 lg:hidden">
|
||||
<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 flex-1 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 items-center gap-6 md:flex">
|
||||
{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="p-2 text-black/40 transition-colors hover:text-black/70 md:hidden dark:text-white/40 dark:hover:text-white/70"
|
||||
onClick={() => setMobileMenuOpen((prev) => !prev)}
|
||||
aria-label="Toggle menu"
|
||||
>
|
||||
{mobileMenuOpen ? (
|
||||
<X className="h-5 w-5" />
|
||||
) : (
|
||||
<Menu className="h-5 w-5" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{mobileMenuOpen && (
|
||||
<div className="flex flex-col gap-4 px-5 pb-2 pt-4 md:hidden">
|
||||
{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="mx-auto flex max-w-[90rem] gap-6 px-5">
|
||||
{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 hover:text-black/60 dark:text-white/35 dark:hover:text-white/60"
|
||||
}`}
|
||||
>
|
||||
{tab.tab}
|
||||
{selectedTab === tab.tab && (
|
||||
<span className="absolute bottom-0 left-0 right-0 h-[2px] rounded-full bg-black/70 dark:bg-white/70" />
|
||||
)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ---- Content area ---- */}
|
||||
<div className="mx-auto flex min-h-0 w-full max-w-[90rem] flex-1">
|
||||
{/* Desktop sidebar */}
|
||||
<aside
|
||||
className={`hidden lg:block ${SIDEBAR_W} flex-shrink-0 overflow-y-auto border-r border-black/[0.06] px-5 pb-8 pt-5 dark:border-white/[0.06]`}
|
||||
>
|
||||
<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="min-w-0 flex-1 overflow-y-auto px-8 pb-8 pt-10 lg:px-20">
|
||||
{children}
|
||||
</main>
|
||||
|
||||
{/* Table of contents */}
|
||||
<TableOfContents headings={headings} />
|
||||
</div>
|
||||
|
||||
{/* ---- Mobile sidebar ---- */}
|
||||
<button
|
||||
className="fixed bottom-4 left-4 z-50 rounded-full bg-black/80 p-3 text-white shadow-lg lg:hidden dark:bg-white/80 dark:text-black"
|
||||
onClick={() => setMobileOpen(!mobileOpen)}
|
||||
aria-label="Toggle sidebar"
|
||||
>
|
||||
{mobileOpen ? <X className="h-5 w-5" /> : <Menu className="h-5 w-5" />}
|
||||
</button>
|
||||
|
||||
{mobileOpen && (
|
||||
<>
|
||||
<div
|
||||
className="fixed inset-0 z-40 bg-black/20 lg:hidden dark:bg-black/50"
|
||||
onClick={() => setMobileOpen(false)}
|
||||
/>
|
||||
<aside className="fixed inset-y-0 left-0 z-40 w-72 overflow-y-auto border-r border-black/[0.06] bg-white px-4 pb-8 pt-4 shadow-xl lg:hidden dark:border-white/[0.06] dark:bg-[#0a0a0a]">
|
||||
<div className="mb-4 flex gap-4 border-b border-black/[0.06] pb-2 dark:border-white/[0.06]">
|
||||
{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 hover:text-black/60 dark:text-white/35 dark:hover:text-white/60"
|
||||
}`}
|
||||
>
|
||||
{tab.tab}
|
||||
{selectedTab === tab.tab && (
|
||||
<span className="absolute bottom-0 left-0 right-0 h-[2px] rounded-full bg-black/70 dark:bg-white/70" />
|
||||
)}
|
||||
</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>
|
||||
);
|
||||
}
|
||||
42
docs-site/components/docs/PageNav.tsx
Normal file
42
docs-site/components/docs/PageNav.tsx
Normal 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="mt-16 flex items-center justify-between border-t border-black/[0.06] pt-6 dark:border-white/[0.06]">
|
||||
{prev ? (
|
||||
<Link
|
||||
href={resolveHref(`/docs/${prev.slug}`)}
|
||||
className="flex items-center gap-2 text-sm text-black/40 no-underline transition-colors hover:text-black/70 dark:text-white/40 dark:hover:text-white/70"
|
||||
>
|
||||
<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 no-underline transition-colors hover:text-black/70 dark:text-white/40 dark:hover:text-white/70"
|
||||
>
|
||||
<span>{next.title}</span>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</Link>
|
||||
) : (
|
||||
<div />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
55
docs-site/components/docs/TableOfContents.tsx
Normal file
55
docs-site/components/docs/TableOfContents.tsx
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"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 w-56 flex-shrink-0 overflow-y-auto px-4 pb-8 pt-8 xl:block">
|
||||
<h4 className="mb-3 text-xs font-medium uppercase tracking-wider text-black/30 dark:text-white/30">
|
||||
On this page
|
||||
</h4>
|
||||
<nav className="space-y-1">
|
||||
{headings.map((heading) => (
|
||||
<a
|
||||
key={heading.id}
|
||||
href={`#${heading.id}`}
|
||||
className={`block py-1 text-[13px] transition-colors ${
|
||||
heading.level === 3 ? "pl-3" : heading.level === 4 ? "pl-6" : ""
|
||||
} ${
|
||||
activeId === heading.id
|
||||
? "font-medium text-black/80 dark:text-white/80"
|
||||
: "text-black/35 hover:text-black/60 dark:text-white/35 dark:hover:text-white/60"
|
||||
}`}
|
||||
>
|
||||
{heading.text}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
48
docs-site/components/docs/mdx/Callout.tsx
Normal file
48
docs-site/components/docs/mdx/Callout.tsx
Normal 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} rounded-r-md p-4`}
|
||||
>
|
||||
<Icon className={`mt-0.5 h-5 w-5 flex-shrink-0 ${config.iconColor}`} />
|
||||
<div className="flex-1 text-sm [&>p:last-child]:mb-0">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
82
docs-site/components/docs/mdx/CardGroup.tsx
Normal file
82
docs-site/components/docs/mdx/CardGroup.tsx
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
"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] bg-white p-5 dark:border-white/[0.08] dark:bg-white/5 h-full${href ? "transition-colors hover:border-black/[0.18] dark:hover:border-white/[0.18]" : ""}`}
|
||||
>
|
||||
{title && (
|
||||
<h3 className="!mt-0 mb-1 text-[15px] font-medium text-black/80 dark:text-white/80">
|
||||
{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="!text-inherit no-underline"
|
||||
>
|
||||
{inner}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
const internalPath = href.startsWith("/docs") ? href : `/docs${href}`;
|
||||
const resolved = resolve(internalPath);
|
||||
|
||||
return (
|
||||
<Link href={resolved} className="!text-inherit no-underline">
|
||||
{inner}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
return inner;
|
||||
}
|
||||
80
docs-site/components/docs/mdx/CodeBlock.tsx
Normal file
80
docs-site/components/docs/mdx/CodeBlock.tsx
Normal 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="pointer-events-none absolute inset-[1px] flex items-start justify-end overflow-hidden rounded-[5px]">
|
||||
<div
|
||||
className="pointer-events-auto flex items-start pl-8 pt-2"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to right, transparent, var(--docs-code-bg-solid) 40%)",
|
||||
}}
|
||||
>
|
||||
<button
|
||||
onClick={handleCopy}
|
||||
className="mr-2 rounded-md p-1.5 text-black/30 transition-colors hover:bg-black/[0.06] hover:text-black/60 dark:text-white/30 dark:hover:bg-white/[0.08] dark:hover:text-white/60"
|
||||
aria-label="Copy code"
|
||||
>
|
||||
{copied ? checkIcon : copyIcon}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
81
docs-site/components/docs/mdx/CodeGroup.tsx
Normal file
81
docs-site/components/docs/mdx/CodeGroup.tsx
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
"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="-mb-px px-4 py-2 text-sm text-black/40 transition-colors data-[state=active]:border-b-2 data-[state=active]:border-black/80 data-[state=active]:text-black/80 dark:text-white/40 dark:data-[state=active]:border-white/80 dark:data-[state=active]:text-white/80"
|
||||
>
|
||||
{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 "";
|
||||
}
|
||||
18
docs-site/components/docs/mdx/Columns.tsx
Normal file
18
docs-site/components/docs/mdx/Columns.tsx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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>;
|
||||
}
|
||||
86
docs-site/components/docs/mdx/DocsAccordion.tsx
Normal file
86
docs-site/components/docs/mdx/DocsAccordion.tsx
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
"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 overflow-hidden rounded-lg border border-black/[0.06] dark:border-white/[0.06]"
|
||||
>
|
||||
{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 transition-colors hover:text-black/90 dark:text-white/70 dark:hover:text-white/90 [&[data-state=open]>svg]:rotate-180">
|
||||
{item.title}
|
||||
<ChevronDown className="h-4 w-4 flex-shrink-0 text-black/30 transition-transform duration-200 dark:text-white/30" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
<AccordionPrimitive.Content className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm">
|
||||
<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 overflow-hidden rounded-lg border border-black/[0.06] dark:border-white/[0.06]"
|
||||
>
|
||||
<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 transition-colors hover:text-black/90 dark:text-white/70 dark:hover:text-white/90 [&[data-state=open]>svg]:rotate-180">
|
||||
{title}
|
||||
<ChevronDown className="h-4 w-4 flex-shrink-0 text-black/30 transition-transform duration-200 dark:text-white/30" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
<AccordionPrimitive.Content className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm">
|
||||
<div className="px-4 pb-4 text-black/60 dark:text-white/60">
|
||||
{children}
|
||||
</div>
|
||||
</AccordionPrimitive.Content>
|
||||
</AccordionPrimitive.Item>
|
||||
</AccordionPrimitive.Root>
|
||||
);
|
||||
}
|
||||
55
docs-site/components/docs/mdx/DocsTabs.tsx
Normal file
55
docs-site/components/docs/mdx/DocsTabs.tsx
Normal 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="-mb-px px-4 py-2 text-sm text-black/40 transition-colors data-[state=active]:border-b-2 data-[state=active]:border-black/80 data-[state=active]:text-black/80 dark:text-white/40 dark:data-[state=active]:border-white/80 dark:data-[state=active]:text-white/80"
|
||||
>
|
||||
{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";
|
||||
18
docs-site/components/docs/mdx/MdxLink.tsx
Normal file
18
docs-site/components/docs/mdx/MdxLink.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
162
docs-site/components/docs/mdx/ModelRecommendations.tsx
Normal file
162
docs-site/components/docs/mdx/ModelRecommendations.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
23
docs-site/components/docs/mdx/OSAutoDetect.tsx
Normal file
23
docs-site/components/docs/mdx/OSAutoDetect.tsx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"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;
|
||||
}
|
||||
55
docs-site/components/docs/mdx/Steps.tsx
Normal file
55
docs-site/components/docs/mdx/Steps.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
70
docs-site/components/docs/mdx/index.tsx
Normal file
70
docs-site/components/docs/mdx/index.tsx
Normal 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} />;
|
||||
},
|
||||
};
|
||||
167
docs-site/components/ui/command.tsx
Normal file
167
docs-site/components/ui/command.tsx
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
"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(
|
||||
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
||||
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]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[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(
|
||||
"placeholder:text-muted-foreground flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none 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(
|
||||
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
||||
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("bg-border -mx-1 h-px", 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(
|
||||
"data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none 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(
|
||||
"text-muted-foreground ml-auto text-xs tracking-widest",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
CommandShortcut.displayName = "CommandShortcut";
|
||||
|
||||
export {
|
||||
Command,
|
||||
CommandDialog,
|
||||
CommandEmpty,
|
||||
CommandGroup,
|
||||
CommandInput,
|
||||
CommandItem,
|
||||
CommandList,
|
||||
CommandSeparator,
|
||||
CommandShortcut,
|
||||
};
|
||||
123
docs-site/components/ui/dialog.tsx
Normal file
123
docs-site/components/ui/dialog.tsx
Normal 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(
|
||||
"bg-background/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 backdrop-blur-sm",
|
||||
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="flex items-center justify-center overflow-y-auto p-4">
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"bg-background 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 relative z-50 my-auto grid w-full max-w-lg gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none">
|
||||
<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-muted-foreground text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
||||
|
||||
export {
|
||||
Dialog,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogClose,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogFooter,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
};
|
||||
72
docs-site/config/docsNav.ts
Normal file
72
docs-site/config/docsNav.ts
Normal 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 };
|
||||
}
|
||||
283
docs-site/lib/docs.ts
Normal file
283
docs-site/lib/docs.ts
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
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:  → 
|
||||
result = result.replace(/\]\(\/images\//g, "](/images/docs/");
|
||||
|
||||
// Rewrite relative image paths:  → 
|
||||
// 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;
|
||||
}
|
||||
20
docs-site/lib/resolveHref.ts
Normal file
20
docs-site/lib/resolveHref.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* 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
6
docs-site/lib/utils.ts
Normal 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
6
docs-site/next-env.d.ts
vendored
Normal 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
12
docs-site/next.config.js
Normal 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
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
50
docs-site/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
6
docs-site/postcss.config.js
Normal file
6
docs-site/postcss.config.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
BIN
docs-site/public/images/continue-logo-light.png
Normal file
BIN
docs-site/public/images/continue-logo-light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
118
docs-site/scripts/build-search-index.ts
Normal file
118
docs-site/scripts/build-search-index.ts
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/**
|
||||
* 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 {
|
||||
// Iteratively strip HTML tags to handle nested/malformed tags
|
||||
let stripped = content;
|
||||
let prev = "";
|
||||
while (prev !== stripped) {
|
||||
prev = stripped;
|
||||
stripped = stripped.replace(/<[^>]+>/g, "");
|
||||
}
|
||||
return stripped
|
||||
.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);
|
||||
});
|
||||
70
docs-site/scripts/copy-doc-images.ts
Normal file
70
docs-site/scripts/copy-doc-images.ts
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* 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();
|
||||
14
docs-site/tailwind.config.ts
Normal file
14
docs-site/tailwind.config.ts
Normal 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;
|
||||
33
docs-site/tsconfig.json
Normal file
33
docs-site/tsconfig.json
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"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"]
|
||||
}
|
||||
|
|
@ -30,8 +30,7 @@ export function useOnboardingCard(): UseOnboardingCard {
|
|||
|
||||
let show: boolean;
|
||||
|
||||
// Always show if we explicitly want to, e.g. passing free trial
|
||||
// and setting up keys
|
||||
// Always show if we explicitly want to, e.g. setting up keys
|
||||
if (onboardingCard.show) {
|
||||
show = true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ const DEFAULT_MOCK_CORE_RESPONSES: MockResponses = {
|
|||
slashCommands: [],
|
||||
contextProviders: [],
|
||||
mcpServerStatuses: [],
|
||||
usePlatform: true,
|
||||
modelsByRole: {
|
||||
chat: [],
|
||||
apply: [],
|
||||
|
|
|
|||
|
|
@ -6,6 +6,16 @@ import {
|
|||
KeyIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useContext, useMemo } from "react";
|
||||
|
||||
const DISCUSSIONS_LINK = "https://github.com/continuedev/continue/discussions";
|
||||
|
||||
function GithubIcon({ className }: { className?: string }) {
|
||||
return (
|
||||
<svg className={className} fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
import { GhostButton } from "../../components";
|
||||
import { useEditModel } from "../../components/mainInput/Lump/useEditBlock";
|
||||
import { useMainEditor } from "../../components/mainInput/TipTapEditor";
|
||||
|
|
|
|||
|
|
@ -2,6 +2,15 @@ import { createAsyncThunk } from "@reduxjs/toolkit";
|
|||
|
||||
import StreamErrorDialog from "../../pages/gui/StreamError";
|
||||
import { analyzeError } from "../../util/errorAnalysis";
|
||||
|
||||
const OVERLOADED_RETRIES = 3;
|
||||
const OVERLOADED_DELAY_MS = 2000;
|
||||
|
||||
function isOverloadedErrorMessage(message?: string): boolean {
|
||||
if (!message) return false;
|
||||
const lower = message.toLowerCase();
|
||||
return lower.includes("overloaded") || lower.includes("529");
|
||||
}
|
||||
import { selectSelectedChatModel } from "../slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../slices/uiSlice";
|
||||
import { ThunkApiType } from "../store";
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -434,6 +434,7 @@
|
|||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
|
|
@ -1313,6 +1314,7 @@
|
|||
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@eslint-community/regexpp": "^4.6.1",
|
||||
|
|
@ -3539,6 +3541,7 @@
|
|||
"integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
|
|
@ -4478,6 +4481,7 @@
|
|||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue