mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
ea16d04599
* docs: split v4/v5 content, fix version switcher end-to-end ## Content restructuring - Split `docs/content/docs/` into `docs/content/docs/v4/` and `docs/content/docs/v5/` so each version is a fully independent content tree with no shared-file coupling - v4 excludes the four pages that are v5-only (AbortController cancellation docs and the serializable-abort-controller internal page) - v5 retains all pages; `preRelease` frontmatter field removed (no longer needed now that each version is its own folder) - Removed `AbortController` / `AbortSignal` from v4 serialization page (section moved to v5 only) ## Fumadocs source - Added `v4docs` and `v5docs` as separate `defineDocs()` collections in `source.config.ts`; shared `docsSchema` (no more `preRelease` field) - `source.ts` exports both `source` (v4, `baseUrl: /docs`) and `v5Source` (v5, same base URL) ## Version routing - `version-source.ts` simplified: `filterPreReleaseFromNodes` and `isPreReleaseUrl` logic removed; v4 tree uses `source`, v5 tree uses `v5Source` + `rewriteNodeUrls` - v4 `page.tsx`: removed `preRelease` guard (v4Source has no such pages) - v5 `page.tsx`: uses `v5Source` for `getPage` / `generateStaticParams` / `generateMetadata`; `v5Link` wrapper rewrites `/docs/…` hrefs to `/v5/docs/…` so inline MDX links stay in the v5 context ## Versioned cookbook - Added `app/[lang]/v5/cookbook/` layout + page (mirrors v4 but uses `v5Source`, `rewriteCookbookUrlForVersion`, and `V5CookbookLink`) - `getCookbookTree` accepts a `versionPrefix` parameter; sidebar URLs are prefixed accordingly (`/v5/cookbook/…`) - `cookbook-tree.ts`: added `skipVersions?: string[]` per-recipe field for version-specific exclusions; `distributed-abort-controller` is marked `skipVersions: ['v5']` ## Version switcher — state & navigation - New `VersionProvider` context (`hooks/geistdocs/use-version.tsx`) backed by `localStorage`: URL is source of truth on versioned pages, `localStorage` carries the preference across non-versioned pages (cookbook overview, worlds, etc.) - `VersionSwitcher` uses `useVersion()` context instead of URL-only detection; now visible on all pages including cookbook - `DesktopMenu` and `MobileMenu` use `activeVersion` from context so the "Docs" and "Cookbook" navbar links resolve to the correct version prefix on every page - `buildVersionUrl` expanded to handle `/cookbook/…` paths alongside `/docs/…`; non-versioned routes (worlds, api) return unchanged - `switchVersion` does a `HEAD` probe before navigating; falls back to the versioned cookbook or docs home if the target page doesn't exist in that version (handles v4-only → v5 and v5-only → v4 cases) ## Cookbook content (v5) - Rewrote `agent-cancellation` recipe using a single `AbortController` pattern; removed Hard Cancellation vs Stop Signal two-approach comparison - Deleted `distributed-abort-controller` recipe from v5 (native `AbortController` serialization makes it unnecessary) - Removed references to distributed-abort-controller from `cookbook/index.mdx` and `common-patterns/timeouts.mdx` Co-authored-by: Cursor <cursoragent@cursor.com> * fix(docs): use abortSignal (not signal) in DurableAgent.stream() options Co-authored-by: Cursor <cursoragent@cursor.com> * fix(docs): update prepack scripts to use versioned content paths Content moved from docs/content/docs/ to docs/content/docs/v5/ on main (pre-release channel). Stable branch will use v4/ after backport. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
110 lines
3.4 KiB
TypeScript
110 lines
3.4 KiB
TypeScript
'use client';
|
|
|
|
import { Check, ChevronDown } from 'lucide-react';
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from '@/components/ui/dropdown-menu';
|
|
import { useVersion } from '@/hooks/geistdocs/use-version';
|
|
import { type DocsVersion, VERSIONS } from '@/lib/geistdocs/versions';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
const VersionIcon = ({ version }: { version: DocsVersion }) => {
|
|
const container = version.preRelease
|
|
? 'bg-orange-100 border-orange-300 dark:bg-orange-800 dark:border-orange-700'
|
|
: 'bg-blue-100 border-blue-300 dark:bg-blue-200 dark:border-blue-700';
|
|
const iconColor = version.preRelease
|
|
? 'text-orange-900 dark:text-orange-200'
|
|
: 'text-blue-900 dark:text-blue-900';
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'flex size-8 shrink-0 items-center justify-center rounded-md border',
|
|
container
|
|
)}
|
|
>
|
|
<svg
|
|
aria-hidden="true"
|
|
className={iconColor}
|
|
height="16"
|
|
viewBox="0 0 16 16"
|
|
width="16"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<path
|
|
clipRule="evenodd"
|
|
d="M1 1.5H1.75H14.25H15V2.25V6.25V7H14.25H8.75V14.25V15H7.25V14.25V7H1.75H1V6.25V2.25V1.5ZM2.5 5.5V3H13.5V5.5H2.5Z"
|
|
fill="currentColor"
|
|
fillRule="evenodd"
|
|
/>
|
|
</svg>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const VersionSwitcher = () => {
|
|
const { activeVersion, switchVersion } = useVersion();
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger
|
|
className={cn(
|
|
'mb-4 flex w-full items-center gap-3 rounded-md border',
|
|
'bg-background-100 px-3 py-2 text-left transition-colors',
|
|
'hover:bg-background-200 focus-visible:outline-hidden'
|
|
)}
|
|
>
|
|
<VersionIcon version={activeVersion} />
|
|
<div className="flex min-w-0 flex-1 flex-col">
|
|
<span className="truncate font-medium text-sm">
|
|
{activeVersion.label}
|
|
</span>
|
|
<span className="truncate text-fd-muted-foreground text-xs">
|
|
{activeVersion.subtitle}
|
|
</span>
|
|
</div>
|
|
<ChevronDown
|
|
aria-hidden="true"
|
|
className="size-4 shrink-0 text-fd-muted-foreground"
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent
|
|
align="start"
|
|
className="w-(--radix-dropdown-menu-trigger-width) min-w-56"
|
|
>
|
|
{VERSIONS.map((version) => {
|
|
const isActive = version.id === activeVersion.id;
|
|
return (
|
|
<DropdownMenuItem
|
|
key={version.id}
|
|
className="flex items-center gap-3 py-2"
|
|
onSelect={() => {
|
|
if (isActive) return;
|
|
switchVersion(version);
|
|
}}
|
|
>
|
|
<VersionIcon version={version} />
|
|
<div className="flex min-w-0 flex-1 flex-col">
|
|
<span className="truncate font-medium text-sm">
|
|
{version.label}
|
|
</span>
|
|
<span className="truncate text-fd-muted-foreground text-xs">
|
|
{version.subtitle}
|
|
</span>
|
|
</div>
|
|
{isActive && (
|
|
<Check
|
|
aria-hidden="true"
|
|
className="size-4 text-green-900 dark:text-green-600"
|
|
/>
|
|
)}
|
|
</DropdownMenuItem>
|
|
);
|
|
})}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
};
|