From a7fb2d30d0178c6e3b7aeb032b3f46567632b3c0 Mon Sep 17 00:00:00 2001 From: Patrick Cartlidge Date: Wed, 18 Dec 2024 11:16:44 +0000 Subject: [PATCH] update config of navigation --- config/navigation.js | 24 ++++++------------------ lib/navigation.js | 8 +++++--- views/partials/_mobile-navigation.njk | 4 ++-- views/partials/_sub-navigation-items.njk | 13 ------------- 4 files changed, 13 insertions(+), 36 deletions(-) delete mode 100644 views/partials/_sub-navigation-items.njk diff --git a/config/navigation.js b/config/navigation.js index ead1e365b2..a6e50247e5 100644 --- a/config/navigation.js +++ b/config/navigation.js @@ -5,40 +5,28 @@ */ const config = [ { - label: 'Get started', - url: 'get-started', text: 'Get started', - href: '/get-started' + href: 'get-started' }, { - label: 'Styles', - url: 'styles', text: 'Styles', - href: '/styles' + href: 'styles' }, { - label: 'Components', - url: 'components', text: 'Components', - href: '/components' + href: 'components' }, { - label: 'Patterns', - url: 'patterns', text: 'Patterns', - href: '/patterns' + href: 'patterns' }, { - label: 'Community', - url: 'community', text: 'Community', - href: '/community' + href: 'community' }, { - label: 'Accessibility', - url: 'accessibility', text: 'Accessibility', - href: '/accessibility' + href: 'accessibility' } ] diff --git a/lib/navigation.js b/lib/navigation.js index d4bbe864d6..b476b42eab 100644 --- a/lib/navigation.js +++ b/lib/navigation.js @@ -23,7 +23,7 @@ module.exports = (config) => (files, metalsmith, done) => { for (const item of items) { // Match navigation item child directories // (for example, ['components/breadcrumbs/index.html', 'components/checkboxes/index.html', ...]) - const itemPaths = metalsmith.match(`${item.url}/*/index.html`, paths) + const itemPaths = metalsmith.match(`${item.href}/*/index.html`, paths) // No sub items required for this path if (!itemPaths.length) { @@ -47,8 +47,8 @@ module.exports = (config) => (files, metalsmith, done) => { // Add subitem to navigation item.items.push({ - url: dirname(itemPath), - label: frontmatter.title, + href: `${dirname(itemPath)}`, + text: frontmatter.title, order: frontmatter.order, theme: frontmatter.theme, @@ -65,6 +65,8 @@ module.exports = (config) => (files, metalsmith, done) => { // Sort navigation sub items using 'order' (optional) item.items?.sort((a, b) => compare(a.order, b.order)) + + item.href = `/${item.href}` } // Add navigation to global variables diff --git a/views/partials/_mobile-navigation.njk b/views/partials/_mobile-navigation.njk index a042358d7f..db7835f7a0 100644 --- a/views/partials/_mobile-navigation.njk +++ b/views/partials/_mobile-navigation.njk @@ -3,8 +3,8 @@