Skip to content

API for clientside router#8571

Merged
martrapp merged 21 commits into
withastro:mainfrom
martrapp:CSRAPI
Sep 27, 2023
Merged

API for clientside router#8571
martrapp merged 21 commits into
withastro:mainfrom
martrapp:CSRAPI

Conversation

@martrapp

@martrapp martrapp commented Sep 15, 2023

Copy link
Copy Markdown
Member

Changes

This is the first version of an API for the existing client side router of the view transition feature.
It provides a method to remote control the page navigation.

import { navigate } from 'astro:transitions/client';
...
  navigate('/somewhere');
or
  navigate('/somewhere', options);
...

It does not support any options yet.
Outlook: First supported option will be: {history: 'push' | 'replace' | 'auto'} (see also https://developer.mozilla.org/en-US/docs/Web/API/Navigation/navigate)

For further discussion see withastro/roadmap#653

Testing

added e2e test

Docs

@changeset-bot

changeset-bot Bot commented Sep 15, 2023

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9a71303

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 Sep 15, 2023
@matthewp

Copy link
Copy Markdown
Contributor

Thanks! Will start reviewing next week.

Comment thread packages/astro/src/transitions/router.ts Outdated
@matthewp

Copy link
Copy Markdown
Contributor

Looks great! I'd be happy to take on the docs part of this. Do you think it makes sense to add the history option now? If it wouldn't be too difficult to support.

@matthewp

Copy link
Copy Markdown
Contributor

I added docs here: withastro/docs#4756

@matthewp

Copy link
Copy Markdown
Contributor

I'll also update the changeset here. We try to have longer changesets for new features.

Comment thread .changeset/fresh-pots-draw.md Outdated
@@ -0,0 +1,5 @@
---
'astro': patch

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 make this be minor?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

changed to minor and copied your very good example from the docs. Feel free to improve the text as I am not a native speaker (well at least not of English)

@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.

I left some comments. Many of them are nitpicks, which I prefixed them with nit:, feel free to ignore them.

Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/router.ts Outdated
Comment thread packages/astro/src/transitions/vite-plugin-transitions.ts
@martrapp

martrapp commented Sep 20, 2023

Copy link
Copy Markdown
Member Author

Will address the review comments on the main branch in another PR (#8617), keep this PR as draft and redo the refactoring for the API just in time for 3.2

matthewp pushed a commit that referenced this pull request Sep 21, 2023
* Update regarding review comments from #8571

* Update regarding review comments from #8571 (2)

* Update regarding review comments from #8571 (3)

* Update regarding review comments from #8571 (4)
@martrapp martrapp marked this pull request as ready for review September 21, 2023 18:04
@matthewp

Copy link
Copy Markdown
Contributor

"Check mergeability" is ok to fail here, it's the thing that blocks PRs with minor changesets. I think there might be a problem with that script.

@martrapp martrapp merged commit 63bc37f into withastro:main Sep 27, 2023
@astrobot-houston astrobot-houston mentioned this pull request Sep 26, 2023
@zanhk

zanhk commented Sep 29, 2023

Copy link
Copy Markdown

Thanks @martrapp

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: minor Change triggers a `minor` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants