Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(next): ctx.isPrerendered #11875

Merged
merged 8 commits into from
Sep 5, 2024
Merged

Conversation

florian-lefebvre
Copy link
Member

@florian-lefebvre florian-lefebvre commented Aug 29, 2024

Changes

  • Adds a new prerender property to the Astro context

Testing

Adds test

Docs

Changeset, withastro/docs#9301

Copy link

changeset-bot bot commented Aug 29, 2024

🦋 Changeset detected

Latest commit: 2fe97bc

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr semver: minor Change triggers a `minor` release labels Aug 29, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@florian-lefebvre
Copy link
Member Author

I wonder if the property should actually be called ctx.prerendered?

@ematipico
Copy link
Member

I wonder if the property should actually be called ctx.prerendered?

We already expose RouteData.prerender to integrations. Better to be consistent

@florian-lefebvre
Copy link
Member Author

idk, prerender is kind of an internal thing, i think we're in the same situation as routePattern for route.route. I'd say the most important is to have something intuitive to use. I'm a bit concerned about confusing people between export const prerender and context.prerender, hence my proposal

@ematipico
Copy link
Member

I usually go for verbose names, so I like isPrerendered, but prerendered is also fine. Any name is fine for me, the code looks good :)

@florian-lefebvre
Copy link
Member Author

Cool! I'll wait for docs review for the naming then

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Here's maybe an idea!

.changeset/long-lions-do.md Outdated Show resolved Hide resolved
@ascorbic
Copy link
Contributor

ascorbic commented Sep 3, 2024

I agree with @ematipico here. isPrerendered is my favourite, with prerendered as second choice.

@florian-lefebvre
Copy link
Member Author

florian-lefebvre commented Sep 3, 2024

I know @Fryuni was thinking about something like isPrerendering. Would you mind explaining why you think it's better than isPrerendered?

@Fryuni
Copy link
Member

Fryuni commented Sep 3, 2024

I might have this preference due to the language difference.

ctx.prerender for me is fine because it is the configuration, so we keep the consistency

ctx.prerendered seems wrong to me because the route has not been pre-rendered, that value is used as part of the rendering process. It reads more as the common request of allowing middleware to run at request-time for pre-rendered routes, in that case the route was pre-rendered, in the past, so it would be correct. But in this case when you read a flag name prerendered, in the past, nothing has been rendered yet, which is what doesn't seem right to me.

ctx.prerendering/ctx.isPrerendering would match what is actually happening at the moment. So those would be second place in my preference (after ctx.prerender which I prefer)

@ascorbic
Copy link
Contributor

ascorbic commented Sep 3, 2024

@Fryuni I think it's probably a language thing. In this context it means "this is a prerendered route", rather than "this route has been prerendered". A property of the route, rather than a state.

@florian-lefebvre
Copy link
Member Author

Yeah I agree with Matt there. I think ctx.prerender is going to be too confusing tbh so I'm against this one

@florian-lefebvre florian-lefebvre changed the title feat(next): ctx.prerender feat(next): ctx.isPrerendered Sep 4, 2024
@florian-lefebvre florian-lefebvre merged commit a8a3d2c into next Sep 5, 2024
14 checks passed
@florian-lefebvre florian-lefebvre deleted the feat/next-ctx-prerender branch September 5, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants