Skip to content

Commit

Permalink
Sort quick search options by group
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed Jun 27, 2023
1 parent 018373c commit 6786c5f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@
mainEl.scrollTo({ top: 0, behavior: 'instant' });
});
const groups = ['components', 'actions', 'stores', 'utils'];
const quickSearchOptions = Object.entries(
import.meta.glob('./docs/**/+page.(md|svelte)', { as: 'raw', eager: true })
).flatMap(([file, source]) => {
const url = file.replace('.', '').replace(/\/\+page.(md|svelte)/, '');
const [_, docs, group, name] = url.split('/');
return {
name,
value: url,
group: group,
};
});
)
.flatMap(([file, source]) => {
const url = file.replace('.', '').replace(/\/\+page.(md|svelte)/, '');
const [_, docs, group, name] = url.split('/');
return {
name,
value: url,
group: group,
};
})
.sort((a, b) => groups.indexOf(a.group) - groups.indexOf(b.group));
</script>

<AppLayout>
Expand Down

1 comment on commit 6786c5f

@vercel
Copy link

@vercel vercel bot commented on 6786c5f Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.