Files
sweet/docs/toc.ts
T
Bartek IwańczukandClaude Opus 4.6 400e217c5e feat: add View Transitions API support for client-side navigation (#3708)
## Summary

- Integrates the [View Transitions
API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API)
into Fresh's existing partials system
- Opt-in via `f-view-transition` attribute, progressive enhancement
(falls back gracefully)
- Wraps all navigation types (link clicks, popstate, form submissions)
in `document.startViewTransition()`

## Usage

```html
<body f-client-nav f-view-transition>
  <!-- your app -->
</body>
```

Customize animations with standard CSS:
```css
::view-transition-old(root) {
  animation: fade-out 0.2s ease-in;
}
::view-transition-new(root) {
  animation: fade-in 0.2s ease-out;
}
```

Per-element transitions work via `view-transition-name`:
```css
.sidebar { view-transition-name: sidebar; }
```

## Design decisions

- **Opt-in** — only activates when `f-view-transition` attribute is
present, can be disabled with `f-view-transition="false"`
- **Progressive** — falls back to regular partial updates when the
browser doesn't support the View Transitions API
- **Minimal** — 35 lines of implementation, integrates into existing
partials infrastructure rather than building a parallel navigation
system

Closes https://github.com/denoland/fresh/issues/3458

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:56:37 +00:00

197 lines
6.5 KiB
TypeScript

import FRESH_VERSIONS_1x from "../versions.json" with { type: "json" };
import LATEST_VERSION_2 from "../packages/fresh/deno.json" with {
type: "json",
};
type RawTableOfContents = Record<
string,
{
label: string;
content: Record<string, RawTableOfContentsEntry>;
}
>;
interface RawTableOfContentsEntry {
title: string;
link?: string;
pages?: [string, string, string?][];
}
const toc: RawTableOfContents = {
latest: {
label: LATEST_VERSION_2.version,
content: {
introduction: {
title: "Introduction",
link: "latest",
},
"getting-started": {
title: "Getting Started",
link: "latest",
},
concepts: {
title: "Concepts",
link: "latest",
pages: [
["architecture", "Architecture", "link:latest"],
["islands", "Islands", "link:latest"],
["app", "App", "link:latest"],
["routing", "Routing", "link:latest"],
["data-fetching", "Data Fetching", "link:latest"],
["middleware", "Middlewares", "link:latest"],
["context", "Context", "link:latest"],
["signals", "Signals", "link:latest"],
["layouts", "Layouts", "link:latest"],
["static-files", "Static files", "link:latest"],
["file-routing", "File routing", "link:latest"],
],
},
advanced: {
title: "Advanced",
link: "latest",
pages: [
["app-wrapper", "App wrapper", "link:latest"],
["layouts", "Layouts", "link:latest"],
["error-handling", "Error handling", "link:latest"],
["partials", "Partials", "link:latest"],
["view-transitions", "View Transitions", "link:latest"],
["forms", "Forms", "link:latest"],
["define", "Define Helpers", "link:latest"],
["serialization", "Serialization", "link:latest"],
["environment-variables", "Environment Variables", "link:latest"],
["head", "<head> element", "link:latest"],
["vite", "Vite Plugin Options", "link:latest"],
["opentelemetry", "OpenTelemetry", "link:latest"],
["api-reference", "API Reference", "link:latest"],
["troubleshooting", "Troubleshooting", "link:latest"],
["builder", "Builder (Legacy)", "link:latest"],
],
},
deployment: {
title: "Deployment",
link: "latest",
pages: [
["deno-deploy", "Deno Deploy", "link:latest"],
["deno-compile", "deno compile", "link:latest"],
["docker", "Docker", "link:latest"],
["cloudflare-workers", "Cloudflare Workers", "link:latest"],
],
},
testing: {
title: "Testing",
link: "latest",
},
plugins: {
title: "Plugins",
link: "latest",
pages: [
["cors", "cors", "link:latest"],
["csrf", "csrf", "link:latest"],
["csp", "csp", "link:latest"],
["ip-filter", "ipFilter", "link:latest"],
["trailing-slashes", "trailingSlashes", "link:latest"],
],
},
examples: {
title: "Examples",
link: "latest",
pages: [
["api-routes", "API Routes", "link:latest"],
["daisyui", "daisyUI", "link:latest"],
["markdown", "Rendering Markdown", "link:latest"],
["rendering-raw-html", "Rendering raw HTML", "link:latest"],
[
"sharing-state-between-islands",
"Sharing state between islands",
"link:latest",
],
["active-links", "Active links", "link:latest"],
["session-management", "Session management", "link:latest"],
["common-patterns", "Common Patterns", "link:latest"],
],
},
"migration-guide": {
title: "Migration Guide",
link: "latest",
},
contributing: {
title: "Contributing",
link: "latest",
},
},
},
"1.x": {
label: FRESH_VERSIONS_1x[0],
content: {
introduction: {
title: "Introduction",
},
"getting-started": {
title: "Getting Started",
pages: [
["create-a-project", "Create a project"],
["running-locally", "Running locally"],
["create-a-route", "Create a route"],
["dynamic-routes", "Dynamic routes"],
["custom-handlers", "Custom handlers"],
["form-submissions", "Form submissions"],
["adding-interactivity", "Adding interactivity"],
["deploy-to-production", "Deploy to production"],
],
},
concepts: {
title: "Concepts",
pages: [
["architecture", "Architecture"],
["server-components", "Server Components"],
["routing", "Routing"],
["routes", "Routes"],
["app-wrapper", "App wrapper"],
["layouts", "Layouts"],
["forms", "Forms"],
["islands", "Interactive islands"],
["static-files", "Static files"],
["middleware", "Middlewares"],
["error-pages", "Error pages"],
["partials", "Partials"],
["data-fetching", "Data fetching"],
["ahead-of-time-builds", "Ahead-of-time Builds"],
["deployment", "Deployment"],
["plugins", "Plugins"],
["updating", "Updating Fresh"],
["server-configuration", "Server configuration"],
],
},
integrations: {
title: "Integrations",
},
examples: {
title: "Examples",
pages: [
["migrating-to-tailwind", "Migrating to Tailwind"],
["modifying-the-head", "Modifying the <head>"],
["writing-tests", "Writing tests"],
["changing-the-src-dir", "Changing the source directory"],
["using-twind-v1", "Using Twind v1"],
["init-the-server", "Initializing the server"],
["using-fresh-canary-version", "Using Fresh canary version"],
["dealing-with-cors", "Dealing with CORS"],
["creating-a-crud-api", "Creating a CRUD API"],
["handling-complex-routes", "Handling complex routes"],
["rendering-markdown", "Rendering markdown"],
["rendering-raw-html", "Rendering raw HTML"],
["sharing-state-between-islands", "Sharing state between islands"],
["using-csp", "Using CSP"],
["active-links", "Styling active links"],
[
"client-side-components-and-libraries",
"Client only side components",
],
],
},
},
},
};
export default toc;