get breadcrumbs implemented
This commit is contained in:
1 parent
ebaebec835
commit
95caa3bac5
1 file changed
+14
-3
@@ -6,11 +6,22 @@ import { Breadcrumb } from '../types'
|
|||||||
|
|
||||||
async function getBreadcrumbs(path: string): Promise<Breadcrumb> {
|
async function getBreadcrumbs(path: string): Promise<Breadcrumb> {
|
||||||
const bc = getPathWaterfall(path)
|
const bc = getPathWaterfall(path)
|
||||||
|
const parts = await Promise.all(bc.map(async href => {
|
||||||
|
const resource = await Page.findByUrl(href)
|
||||||
|
|
||||||
return bc.map(href => ({
|
if (!resource) {
|
||||||
name: href,
|
return null
|
||||||
href,
|
}
|
||||||
|
|
||||||
|
const name = resource.title
|
||||||
|
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
href,
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
return parts.filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getItem(req: Request, res: Response) {
|
export async function getItem(req: Request, res: Response) {
|
||||||
|
|||||||
Reference in new issue
Block a user