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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/client/theme-default/components/NextAndPrevLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<div v-if="hasLinks" class="next-and-prev-link">
<div class="container">
<div class="prev">
<a v-if="prev" class="link" :href="prev.link">
<a v-if="prev" class="link" :href="withBase(prev.link)">
<ArrowLeft class="icon icon-prev" />
<span class="text">{{ prev.text }}</span>
</a>
</div>
<div class="next">
<a v-if="next" class="link" :href="next.link">
<a v-if="next" class="link" :href="withBase(next.link)">
<span class="text">{{ next.text }}</span>
<ArrowRight class="icon icon-next" />
</a>
Expand All @@ -20,6 +20,7 @@
<script lang="ts">
import { defineComponent } from 'vue'
import { useNextAndPrevLinks } from '../composables/nextAndPrevLinks'
import { withBase } from '../utils'
import ArrowLeft from './icons/ArrowLeft.vue'
import ArrowRight from './icons/ArrowRight.vue'

Expand All @@ -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!

}
}
})
Expand Down