1
0
Fork 0

feat(shared): Moved breadcrumbs to shared component

This commit is contained in:
Joost De Cock 2022-05-31 10:12:54 +02:00
parent 963e61ab28
commit 2f7d6e4505
6 changed files with 77 additions and 162 deletions

View file

@ -1,4 +1,5 @@
import { useState } from 'react'
import get from 'lodash.get'
import set from 'lodash.set'
// Stores state in local storage
import useLocalStorage from 'shared/hooks/useLocalStorage.js'
@ -97,6 +98,16 @@ function useApp(full = true) {
setNavigation(set(navigation, path, content))
}
/*
* Helper method to get title from navigation structure
*/
const getTitle = slug => get(navigation, slug).__title
/*
* Helper method to construct breadcrumb from navigation structure
*/
const getBreadcrumb = slug => ({ title: get(navigation, slug).__title, slug })
return {
// Static vars
site: 'org',
@ -123,6 +134,10 @@ function useApp(full = true) {
// State handlers
togglePrimaryMenu,
// Navigation
getTitle,
getBreadcrumb,
}
}