diff --git a/views/partials/header.ejs b/views/partials/header.ejs index ddb1bfd..e7550a8 100644 --- a/views/partials/header.ejs +++ b/views/partials/header.ejs @@ -15,14 +15,81 @@ + <% + const navItems = (config?.nav || []); + const mainItems = []; + const productItems = []; + const resourceItems = []; + + navItems.forEach((item) => { + const key = `${item.label || ''} ${item.href || ''}`.toLowerCase(); + + if ((item.href || '') === '/') { + mainItems.push(item); + return; + } + + if (/about/.test(key)) { + mainItems.push(item); + return; + } + + if (/shop|training|report/.test(key)) { + productItems.push(item); + return; + } + + if (/literature|testimonial|first|occlusion|news|update|video|media/.test(key)) { + resourceItems.push(item); + return; + } + + mainItems.push(item); + }); + + const uniqueByHref = (arr) => arr.filter((it, idx, src) => src.findIndex(x => x.href === it.href) === idx); + const main = uniqueByHref(mainItems); + const products = uniqueByHref(productItems); + const resources = uniqueByHref(resourceItems); + %> +