Skip to content

Commit d96ef28

Browse files
authored
feat: preserve search query when switching collections (#379)
1 parent adcee5a commit d96ef28

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/components/Drawer.vue

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@ const route = useRoute()
77
const current = computed(() => route.path.split('/').slice(-1)[0])
88
99
const collections = computed(() => {
10-
if (categorySearch.value) {
11-
return filteredCollections.value
12-
}
13-
else {
14-
return [
15-
{ id: 'all', name: 'All' },
16-
{ id: 'recent', name: 'Recent' },
17-
...sortedCollectionsInfo.value,
18-
]
19-
}
10+
const _collections = categorySearch.value
11+
? filteredCollections.value
12+
: [
13+
{ id: 'all', name: 'All' },
14+
{ id: 'recent', name: 'Recent' },
15+
...sortedCollectionsInfo.value,
16+
]
17+
18+
return _collections.map(collection => ({
19+
...collection,
20+
to: {
21+
name: 'collection-id',
22+
params: { id: collection.id },
23+
query: {
24+
s: route.query.s,
25+
},
26+
},
27+
}))
2028
})
2129
</script>
2230

@@ -51,7 +59,7 @@ const collections = computed(() => {
5159
v-for="collection in collections"
5260
:key="collection.id"
5361
class="px-3 py-1 flex border-b border-base"
54-
:to="`/collection/${collection.id}`"
62+
:to="collection.to"
5563
>
5664
<div
5765
class="flex-auto py-1"

0 commit comments

Comments
 (0)