Skip to content

Commit

Permalink
feat(upgrade-to-nuxt-3): Update generatePostsRoute function
Browse files Browse the repository at this point in the history
- Update postsRoute generation in [domain].vue
- Update path generation in RouterHelper.ts

Issue: upgrade-to-nuxt-3
  • Loading branch information
AlejandroAkbal committed Jan 12, 2024
1 parent b3f8115 commit ab918e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions assets/js/RouterHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import type { RouteLocationRaw } from 'vue-router'
import { isEmpty, isNil, omitBy } from 'lodash-es'

export function generatePostsRoute(
path: string = '/posts',
domain?: string | undefined | null,
page?: number | undefined | null,
tags?: Tag[] | undefined | null,
filters?: Object | undefined | null
) {
const route: RouteLocationRaw = {
path: '/posts',
path,
query: {}
}

if (domain != null) {
route.path = `/posts/${domain}`
route.path = `${path}/${domain}`
}

if (page != null) {
Expand Down
3 changes: 2 additions & 1 deletion pages/posts/[domain].vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
filters = selectedFilters.value
}
const postsRoute = generatePostsRoute(domain, page, tags, filters)
const postsRoute = generatePostsRoute(undefined, domain, page, tags, filters)
await navigateTo({ ...postsRoute }, { replace })
}
Expand Down Expand Up @@ -368,6 +368,7 @@
const canonicalUrl = computed(() => {
const rawRoute = generatePostsRoute(
undefined,
selectedBooru.value.domain,
selectedPage.value,
selectedTags.value,
Expand Down

0 comments on commit ab918e8

Please sign in to comment.