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

Ensure that the base is used for previous and next links #139

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

ElMassimo
Copy link
Contributor

Description 📖

This pull request fixes next and previous links in sites with a non-default base configuration.

Background 📜

#130 recently moved the previous and next page link calculation to the client side.

Because links used in the sidebar don't include the base, rendering them directly causes them to have an incorrect URL.

@@ -35,7 +36,8 @@ export default defineComponent({
return {
hasLinks,
prev,
next
next,
withBase,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another option would be to use withBase in getFlatSidebarLinksFromArray:

    if (item.link) {
      links.push({ text: item.text, link: withBase(item.link) })
    }

However, that would also require using withBase in currentPath for the comparison in currentIndex to work as expected.

Calling it in the component seemed consistent with how the logo is currently being rendered.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I would like to refactor the use of withBase, but for now it's being used everywhere so I think this is fine!

Copy link
Member

@kiaking kiaking left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Totally missed this one 👀 Great work!

@@ -35,7 +36,8 @@ export default defineComponent({
return {
hasLinks,
prev,
next
next,
withBase,
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I would like to refactor the use of withBase, but for now it's being used everywhere so I think this is fine!

@kiaking kiaking added the bug Something isn't working label Nov 20, 2020
@kiaking kiaking merged commit 018a9b4 into vuejs:master Nov 20, 2020
@ElMassimo ElMassimo deleted the fix/base-in-next-and-previous-links branch November 20, 2020 19:35
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants