From ce3f23e52decffc45f09b85390f71c53d1caffb0 Mon Sep 17 00:00:00 2001 From: Joshua Seigler Date: Wed, 11 Mar 2020 10:19:41 -0400 Subject: [PATCH] feat(nav): Enable top nav manual ordering Add the "weight" parameter to categories Add sorting code to data.js to sort by the new parameter --- data/docs.yaml | 1 + data/tools.yaml | 1 + scripts/data.js | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/data/docs.yaml b/data/docs.yaml index 5d2260d..6058540 100644 --- a/data/docs.yaml +++ b/data/docs.yaml @@ -2,6 +2,7 @@ title: Docs color: green icon: stroke_decentralization description: Dash Platorm Documentation resources. +weight: 10 content: - title: DashJS website: https://dashevo.github.io/DashJS diff --git a/data/tools.yaml b/data/tools.yaml index 0ae6549..db02fd2 100644 --- a/data/tools.yaml +++ b/data/tools.yaml @@ -2,6 +2,7 @@ title: Tools color: yellow icon: stroke_code description: Tools for developing with Dash Platform. +weight: 6 content: - title: EvoNet Faucet website: http://devnet-evonet-1117662964.us-west-2.elb.amazonaws.com/ diff --git a/scripts/data.js b/scripts/data.js index ff73cf3..9f53f89 100644 --- a/scripts/data.js +++ b/scripts/data.js @@ -13,10 +13,11 @@ module.exports = fs.readdirSync(dir) file.slug = slugify(file.title) file.type = 'category' - file.content = file.content.map(({ title, description, ...meta }, i) => ({ + file.content = file.content.map(({ title, description, weight, ...meta }, i) => ({ ...meta, title: trimIfExists(title), description: trimIfExists(description), + weight: weight, category: file.slug, color: file.color, index: i @@ -32,3 +33,4 @@ module.exports = fs.readdirSync(dir) return file }) .sort((a, b) => sortAbc(a.title, b.title)) + .sort((a, b) => sortInv(a.weight, b.weight))