get breadcrumbs implemented

This commit is contained in:
tmshv committed 2020-02-23 03:48:45 +03:00
1 parent ebaebec835
commit 95caa3bac5
1 file changed
+14 -3
+14 -3
View File
@@ -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) {