From a5205b2a8e87765a3e61b11a3fb88d2e578c84cb Mon Sep 17 00:00:00 2001 From: Roscoe Rubin-Rottenberg <118622417+knotbin@users.noreply.github.com> Date: Tue, 5 Aug 2025 18:17:24 -0400 Subject: [PATCH] docs: add correct ctx.state example to init and docs (#3147) - Correct outdated, non-functional and confusing "Removal of
component" section of migration guide in the docs to be real functional code that uses Fresh 2 and define helpers correctly - Added example of ctx.state being used for a head component (title) because it's something almost every single project will need to know how to do. - Small change to define docs use of define.page to be more in line with its use commonly - Removed mention of deno-puppeteer - a non-official repository that hasn't been updated in three years - needing to be installed from `CONTRIBUTING.md` --- .github/CONTRIBUTING.md | 4 +-- docs/canary/examples/migration-guide.md | 41 ++++++++++++++++--------- init/src/init.ts | 18 ++++++----- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 2fcb9cea..98186a54 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,6 +2,4 @@ ## Submitting a pull request -First, please be sure to -[install Puppeteer](https://github.com/lucacasonato/deno-puppeteer#installation). -Then, please ensure `deno task ok` is run and successfully passes. +First, please be sure to ensure `deno task ok` is run and successfully passes. diff --git a/docs/canary/examples/migration-guide.md b/docs/canary/examples/migration-guide.md index c2534a3b..de2a016b 100644 --- a/docs/canary/examples/migration-guide.md +++ b/docs/canary/examples/migration-guide.md @@ -128,33 +128,44 @@ The `` component was used in Fresh 1.x to add additional tags to the removed in preparation and due to performance concerns as it required a complex machinery in the background to work. -Instead, passing head-related data is best done via `ctx.state` +Instead, passing head-related data is best done via `ctx.state`, which can be +easily set through the [define helper](/docs/canary/advanced/define). -```tsx routes/about.tsx -export const handler = { - GET(ctx) { - // Set a route specific data in a handler - ctx.state.title = "About Me"; - return page(); - }, -}; -``` +```tsx +// utils.ts +export interface State { + title?: string; +} +export const define = createDefine