From c8e911b4303cc3fbc9001713bf99594548e6c47e Mon Sep 17 00:00:00 2001 From: Reinaldo Schiehll Date: Sun, 26 May 2019 01:51:08 -0300 Subject: [PATCH] Sort items by the order meta --- .kerbs/other.mdx | 3 ++- .kerbs/overview.mdx | 3 ++- src/components/layout/index.js | 8 +++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.kerbs/other.mdx b/.kerbs/other.mdx index 6a83fea..83f857e 100644 --- a/.kerbs/other.mdx +++ b/.kerbs/other.mdx @@ -1,5 +1,6 @@ export const meta = { - title: 'Other' + title: 'Other', + order: 1 } # Other diff --git a/.kerbs/overview.mdx b/.kerbs/overview.mdx index e31f4ae..3209c81 100644 --- a/.kerbs/overview.mdx +++ b/.kerbs/overview.mdx @@ -1,7 +1,8 @@ import Red from 'components/red' export const meta = { - title: 'Overview with a big title' + title: 'Overview with a big title', + order: 0 } # Overview diff --git a/src/components/layout/index.js b/src/components/layout/index.js index 67b3aee..1b0aa96 100644 --- a/src/components/layout/index.js +++ b/src/components/layout/index.js @@ -64,7 +64,13 @@ const Layout = () => { id: 'id' }) setKerbs(allKerbs.current) - setNavItems(navItems.concat(allKerbs.current)) + setNavItems( + navItems.concat( + allKerbs.current.sort( + (a, b) => (a?.meta?.order || 0) - b?.meta?.order + ) + ) + ) } loadKerbs()