Skip to content

add correct ctx.state example to init and docs - #3147

Merged
marvinhagemeister merged 7 commits into
freshframework:mainfrom
knotbin:init-define-title
Aug 5, 2025
Merged

add correct ctx.state example to init and docs#3147
marvinhagemeister merged 7 commits into
freshframework:mainfrom
knotbin:init-define-title

Conversation

@knotbin

@knotbin knotbin commented Jul 28, 2025

Copy link
Copy Markdown
Contributor
  • 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

Comment thread docs/canary/advanced/define.md Outdated
// routes/about.tsx
import { define } from "../utils.ts";

export default define.page(function AboutPage(ctx) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check if we support this style of declaring handlers. Not sure if we do.

@knotbin knotbin Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how the init template project declares its pages (even before my changes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point to where that's the case? I can't find something like that anywhere. I've never seen this pattern around fresh:

export default define.page(function AboutPage(ctx) {
  GET(ctx) { // <-- This looks like an error. Where is the `GET` function coming from?
    //...snip
  }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're 100% right I just updated that. Sorry for the misunderstanding I thought your comment was about the export default define.page(function AboutPage(ctx) { line above the one that caused the error.

@marvinhagemeister marvinhagemeister left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, thanks!

@marvinhagemeister
marvinhagemeister merged commit a5205b2 into freshframework:main Aug 5, 2025
7 checks passed
@knotbin
knotbin deleted the init-define-title branch August 5, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants