Skip to content

Commit

Permalink
fix: removing /home/ prefix from BaseLink (#596)
Browse files Browse the repository at this point in the history
* removing /home/ prefix from BaseLink

* adding guards for then toValue is an object
  • Loading branch information
stephiescastle authored Sep 5, 2024
1 parent 7fe9335 commit 53fb860
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/vue/src/components/BaseLink/BaseLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ export default defineComponent({
return 'noopener'
}
return undefined
},
computedTo() {
let toValue = this.to
// filter out unnecessary `/home/` prefix from wagtail default site urlPaths
if (toValue && typeof toValue === 'string' && toValue.startsWith('/home/')) {
toValue = toValue.replace('/home/', '/')
}
return toValue
}
},
methods: {
Expand All @@ -155,10 +163,10 @@ export default defineComponent({
<div>
<!-- annoyingly repetive due to complexities around `to` and @click.native -->
<nuxt-link
v-if="to"
v-if="computedTo"
class="group"
:class="computedClass"
:to="to"
:to="computedTo"
:target="theTarget"
:rel="theRel"
:aria-label="ariaLabel"
Expand Down

0 comments on commit 53fb860

Please sign in to comment.