-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update layout for algolia search
- Loading branch information
1 parent
2fbc60a
commit e910a7f
Showing
4 changed files
with
158 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const defaultCategory = 'Community Code'; | ||
|
||
// Order by most specific to least specific. | ||
// e.g. `/js/ethers/api/v5` before `/js/ethers` | ||
const categories = [['/tutorials', 'Community Code Guides']] as const; | ||
|
||
/** | ||
* Returns the category of the current route. | ||
* Primarily this is for the algolia docsearch | ||
*/ | ||
export const useCategory = () => { | ||
const route = useRoute(); | ||
const category = ref(defaultCategory); | ||
// for if we ever have i18n routes, remove the language prefix | ||
// const langAgnosticPath = route.path.replace(/\/\w\w(-\w\w)?\//, ''); | ||
for (const [path, label] of categories) { | ||
if (route.path.startsWith(path)) { | ||
category.value = label; | ||
break; | ||
} | ||
} | ||
return category; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters