Skip to content

Commit

Permalink
Merge pull request #143 from nih-sparc/fix-history-stack-for-back-button
Browse files Browse the repository at this point in the history
fixed history stack when internally redirecting
  • Loading branch information
egauzens authored Jun 28, 2024
2 parents 319926c + 9ca6033 commit 38aba78
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 19 deletions.
3 changes: 2 additions & 1 deletion pages/about/[aboutDetailsId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export default {
return await $contentfulClient.getEntry(params.aboutDetailsId).then(async (response) => {
const slug = pathOr("", ['fields', 'slug'], response)
if (!isEmpty(slug)) {
await navigateTo(`/about/${slug}`)
const router = useRouter()
await router.replace({ path: `/about/${slug}` })
}
return response
})
Expand Down
3 changes: 2 additions & 1 deletion pages/about/get-involved/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export default {
async setup() {
const route = useRoute()
const newPath = route.href.replace('/about/get-involved', '/about')
await navigateTo(newPath, { redirectCode: 301 })
const router = useRouter()
await router.replace({ path: newPath })
}
}
</script>
3 changes: 2 additions & 1 deletion pages/about/sparc-portal/metrics/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export default {
name: 'MetricsPage',
async setup() {
await navigateTo("/about/metrics", { redirectCode: 301 })
const router = useRouter()
await router.replace({ path: "/about/metrics" })
},
}
</script>
3 changes: 2 additions & 1 deletion pages/about/team-and-leadership/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export default {
async setup() {
const route = useRoute()
const newPath = route.href.replace('/about/team-and-leadership', '/about')
await navigateTo(newPath, { redirectCode: 301 })
const router = useRouter()
await router.replace({ path: newPath })
}
}
</script>
3 changes: 2 additions & 1 deletion pages/about/what-we-offer/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export default {
async setup() {
const route = useRoute()
const newPath = route.href.replace('/about/what-we-offer', '/about')
await navigateTo(newPath, { redirectCode: 301 })
const router = useRouter()
await router.replace({ path: newPath })
}
}
</script>
3 changes: 2 additions & 1 deletion pages/data/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export default {
if (focusQuery) {
newPath += `&selectedProjectsAnatomicalFocusIds=${focusQuery}`
}
return navigateTo(newPath)
const router = useRouter()
await router.replace({ path: newPath })
}
const { $algoliaClient } = useNuxtApp()
const algoliaSortOptions = [
Expand Down
11 changes: 6 additions & 5 deletions pages/maps/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
import { pathOr, isEmpty } from 'ramda'
import { infoMessage } from '@/utils/notification-messages'
export default {
async setup() {
setup() {
const route = useRoute()
const emptyParam = pathOr('', ['query'], route)
const query = pathOr('', ['query'], route)
let newPath = ''
if (isEmpty(emptyParam)) {
if (isEmpty(query)) {
newPath = route.href.replace('/maps', '/apps')
infoMessage('All available map viewers have now been integrated with SPARC Apps and can be found below!')
} else {
newPath = route.href.replace('/maps', '/apps/maps')
newPath = route.href.replace('/maps', `/apps/maps?${query}`)
}
await navigateTo(newPath, { redirectCode: 301 })
const router = useRouter()
router.replace({ path: newPath, query: query })
}
}
</script>
5 changes: 3 additions & 2 deletions pages/news-and-events/community-spotlight/submit/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script>
export default {
async setup() {
await navigateTo("/contact-us?type=story", { redirectCode: 301 })
},
const router = useRouter()
await router.replace({ path: "/contact-us?type=story" })
}
}
</script>
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script>
export default {
async setup() {
await navigateTo("/news-and-events/community-spotlight?selectedSpotlightTypes=successStory", { redirectCode: 301 })
const router = useRouter()
await router.replace({ path: "/news-and-events/community-spotlight?selectedSpotlightTypes=successStory" })
}
}
</script>
</script>
5 changes: 3 additions & 2 deletions pages/news-and-events/submit/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script>
export default {
async setup() {
await navigateTo("/contact-us?type=story", { redirectCode: 301 })
},
const router = useRouter()
await router.replace({ path: "/contact-us?type=story" })
}
}
</script>
3 changes: 2 additions & 1 deletion pages/projects/[projectId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
export default {
async setup() {
const route = useRoute()
const router = useRouter()
const newPath = route.href.replace('/projects', '/about/projects')
await navigateTo(newPath, { redirectCode: 301 })
await router.replace({ path: newPath })
},
}
</script>
3 changes: 2 additions & 1 deletion pages/resources/[resourceId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
export default {
async setup() {
const route = useRoute()
const router = useRouter()
const newPath = route.href.replace('/resources/', '/tools-and-resources/')
await navigateTo(newPath, { redirectCode: 301 })
await router.replace({ path: newPath })
},
}
</script>

0 comments on commit 38aba78

Please sign in to comment.