Skip to content

Commit

Permalink
feat: generate route with default url state
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Oct 17, 2021
1 parent 4a79c63 commit b83fefa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
18 changes: 18 additions & 0 deletions assets/js/RouterHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,22 @@ export class RouterHelper {

return route
}

/**
* @param {Store<*> | boolean | ((typedArray: (Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array), index: number, value: number) => number) | ((credential: Credential) => Promise<Credential>) | ((typedArray: (BigInt64Array | BigUint64Array), index: number, value: bigint) => bigint)} store
* @param {string} [domain]
* @param {number} [page]
* @param {string[]} [tags]
*/
static generatePostsRouteWithDefaults(store, domain, page, tags) {
if (domain == null) {
domain = store.getters['booru/getActiveBooru'].domain
}

if (page == null) {
page = store.getters['booru/getActiveBooruType'].initialPageID
}

return RouterHelper.generatePostsRoute(domain, page, tags)
}
}
11 changes: 7 additions & 4 deletions components/pages/posts/post/Post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@
<NuxtLink
:key="tag"
:to="
generatePostsRoute(getActiveBooru.domain, undefined, [
tag,
])
generatePostsRouteWithDefaults(
$nuxt.$store,
undefined,
undefined,
[tag]
)
"
class="tag link"
>
Expand Down Expand Up @@ -319,7 +322,7 @@ export default {
},
methods: {
generatePostsRoute: RouterHelper.generatePostsRoute,
generatePostsRouteWithDefaults: RouterHelper.generatePostsRouteWithDefaults,
toggleTags() {
this.isActive = !this.isActive
Expand Down

0 comments on commit b83fefa

Please sign in to comment.