Skip to content

Add base to paginate - #11253

Merged
ematipico merged 17 commits into
nextfrom
add-base-to-paginate
Aug 28, 2024
Merged

ematipico merged 17 commits into
nextfrom
add-base-to-paginate

Conversation

@kevinzunigacuellar

@kevinzunigacuellar kevinzunigacuellar commented Jun 14, 2024 •

Copy link
Copy Markdown
Member

Changes

Testing

Updated tests

Docs

withastro/docs#8569

withastro/docs#9200

@changeset-bot

changeset-bot Bot commented Jun 14, 2024 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d840819

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 the pkg: astro Related to the core `astro` package (scope) label Jun 14, 2024

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A changeset is missing

Comment thread packages/astro/src/core/render/paginate.ts Outdated
Comment thread packages/astro/src/core/render/paginate.ts Outdated
@bluwy

bluwy commented Jun 14, 2024

Copy link
Copy Markdown
Member

There's no changeset, but presumably this would be a major as existing users would've manually added the base now, and we might break them?

@ematipico

Copy link
Copy Markdown
Member

But isn't this a bug? Users were using a workaround for the bug. Or do we document that those URLs were meant to be without base?

@github-actions github-actions Bot added the semver: major Change triggers a `major` release label Jun 14, 2024

@github-actions github-actions Bot 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.

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

@bluwy

bluwy commented Jun 14, 2024

Copy link
Copy Markdown
Member

@ematipico The docs doesn't explicit mention about the base. I think it has always worked this way for very long and it's risky to fix it now even if it may be a bug.

I was thinking of documenting that you need to add the base manually. Or maybe paginate() can accept an option to prepend base, which we will turn on automatically in Astro 5?

@ematipico

Copy link
Copy Markdown
Member

@ematipico The docs doesn't explicit mention about the base. I think it has always worked this way for very long and it's risky to fix it now even if it may be a bug.

I was thinking of documenting that you need to add the base manually. Or maybe paginate() can accept an option to prepend base, which we will turn on automatically in Astro 5?

Yeah, that sounds like a reasonable approach!

@kevinzunigacuellar

Copy link
Copy Markdown
Member Author

I am leaning towards the most simple solution to just edit docs and mention that base is not prepended by default. If it's okay with everyone, I will close the PR an open one in docs. Thanks for all the support @bluwy and @ematipico

@ematipico

Copy link
Copy Markdown
Member

I am leaning towards the most simple solution to just edit docs and mention that base is not prepended by default. If it's okay with everyone, I will close the PR an open one in docs. Thanks for all the support @bluwy and @ematipico

Make sure to not delete the branch. We will recreate this PR once we start the works towards Astro 5.0

@sarah11918 sarah11918 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggestion for a style of changeset here!

(PLT2204)

Comment thread .changeset/twenty-cobras-push.md Outdated
@ematipico
ematipico force-pushed the add-base-to-paginate branch from cbe8438 to 6c54fbd Compare August 13, 2024 10:26
ematipico and others added 2 commits August 13, 2024 11:29
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@ematipico

Copy link
Copy Markdown
Member

@sarah11918 Code snippet added here 9403870 (#11253)

@sarah11918

Copy link
Copy Markdown
Member

Quick reminder (as will be the process going forward) that this will require an update to the 5.0.0-beta branch v5 upgrade guide under the appropriate heading there!

@kevinzunigacuellar is a maintainer, so can commit directly there. But, might not make the obvious connection to the Linear task. So especially @ematipico and @bluwy whom I suspect will be helping out a lot with non-core PRs, please help everyone out who doesn't use Linear! 🙌

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @kevinzunigacuellar!

How does this change impact pages not directly in src/pages/?

As an example:

  • I have base: "blog" in my config
  • I have src/pages/categories/[...category].astro which uses paginate()

The correct inclusion of base would be /blog/categories/2.

Does this PR do that or does it generate /categores/blog/2?

Comment thread .changeset/twenty-cobras-push.md Outdated
Comment thread .changeset/twenty-cobras-push.md Outdated
@sarah11918

Copy link
Copy Markdown
Member

Noting that the place to update this information in the upgrade guide is here:

Preview: https://5-0-0-beta--astro-docs-2.netlify.app/en/guides/upgrade-to/v5/#changed-add-base-to-paginate-plt2204
File: https://github.com/withastro/docs/edit/5.0.0-beta/src/content/docs/en/guides/upgrade-to/v5.mdx (line 223)

Will also require an update to:
https://docs.astro.build/en/reference/api-reference/#pageurlprev and following entries that all say "If a value is set for base, prepend the base path to the URL"

@sarah11918

Copy link
Copy Markdown
Member

@kevinzunigacuellar Does this also affect page.url.first and page.url.last? If so, then the changeset shouldn't only mention previous and next. If not, isn't that kind of confusing? 😅

Note: I think first and last are very recent additions, maybe even before you made this PR!

@ematipico

Copy link
Copy Markdown
Member

Thanks for the PR @kevinzunigacuellar!

How does this change impact pages not directly in src/pages/?

As an example:

* I have `base: "blog"` in my config

* I have `src/pages/categories/[...category].astro` which uses `paginate()`

The correct inclusion of base would be /blog/categories/2.

Does this PR do that or does it generate /categores/blog/2?

The base is always prefixed to any route, regardless of their position the file system. In your example, the emitted route is /blog/categories/2

@ematipico

Copy link
Copy Markdown
Member

@sarah11918 I updated the changeset to include all the APIs that were modified

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The base is always prefixed to any route, regardless of their position the file system. In your example, the emitted route is /blog/categories/2

Fantastic, thanks for the clarification @ematipico. In that case approving conceptually 😁

Thanks again for the PR @kevinzunigacuellar and for taking it to the finish line Ema 💜

@ematipico
ematipico merged commit 4e5cc5a into next Aug 28, 2024
@ematipico
ematipico deleted the add-base-to-paginate branch August 28, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) semver: major Change triggers a `major` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The "page" prop in paginated dynamic routes doesn’t handle base URLs

6 participants