From f454cfc8b14991df42e79d0e4acaa11cefb36ee9 Mon Sep 17 00:00:00 2001 From: HZ991 Date: Mon, 30 Sep 2024 15:50:50 +1000 Subject: [PATCH 1/2] added: manual sorting for developers menu --- .../navigation/navigation.component.tsx | 10 ++++++- .../design/eslint-configuration/content.mdoc | 0 .../index.yaml | 0 .../design/installation/content.mdoc | 0 .../design/pre-requisites/content.mdoc | 0 .../design/resources/content.mdoc | 0 .../{1-set-up => set-up}/index.yaml | 0 .../design/unit-testing/content.mdoc | 0 .../index.yaml | 0 .../design/using-brands/content.mdoc | 0 .../index.yaml | 0 .../accessibilityDemo.mdoc | 0 .../design/using-components/content.mdoc | 0 .../index.yaml | 0 .../relatedArticles.mdoc | 0 apps/site/src/utils/format.ts | 28 +++++++++++++------ 16 files changed, 28 insertions(+), 10 deletions(-) rename apps/site/src/content/design-system/get-started/developers/{4-eslint => eslint-configuration}/design/eslint-configuration/content.mdoc (100%) rename apps/site/src/content/design-system/get-started/developers/{4-eslint => eslint-configuration}/index.yaml (100%) rename apps/site/src/content/design-system/get-started/developers/{1-set-up => set-up}/design/installation/content.mdoc (100%) rename apps/site/src/content/design-system/get-started/developers/{1-set-up => set-up}/design/pre-requisites/content.mdoc (100%) rename apps/site/src/content/design-system/get-started/developers/{1-set-up => set-up}/design/resources/content.mdoc (100%) rename apps/site/src/content/design-system/get-started/developers/{1-set-up => set-up}/index.yaml (100%) rename apps/site/src/content/design-system/get-started/developers/{5-unit-testing => unit-testing}/design/unit-testing/content.mdoc (100%) rename apps/site/src/content/design-system/get-started/developers/{5-unit-testing => unit-testing}/index.yaml (100%) rename apps/site/src/content/design-system/get-started/developers/{3-using-brands => using-brands}/design/using-brands/content.mdoc (100%) rename apps/site/src/content/design-system/get-started/developers/{3-using-brands => using-brands}/index.yaml (100%) rename apps/site/src/content/design-system/get-started/developers/{2-using-components => using-components}/accessibilityDemo.mdoc (100%) rename apps/site/src/content/design-system/get-started/developers/{2-using-components => using-components}/design/using-components/content.mdoc (100%) rename apps/site/src/content/design-system/get-started/developers/{2-using-components => using-components}/index.yaml (100%) rename apps/site/src/content/design-system/get-started/developers/{2-using-components => using-components}/relatedArticles.mdoc (100%) diff --git a/apps/site/src/app/design-system/components/sidebar/components/navigation/navigation.component.tsx b/apps/site/src/app/design-system/components/sidebar/components/navigation/navigation.component.tsx index c845c85e0..7dcf565ad 100644 --- a/apps/site/src/app/design-system/components/sidebar/components/navigation/navigation.component.tsx +++ b/apps/site/src/app/design-system/components/sidebar/components/navigation/navigation.component.tsx @@ -6,7 +6,7 @@ import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { useState } from 'react'; -import { formatComponentSlug } from '@/utils/format'; +import { formatComponentSlug, formatNavItems, sortDeveloperMenu, sortMenu } from '@/utils/format'; import { useSidebar } from '../../sidebar.context'; @@ -29,6 +29,14 @@ export function Navigation({ items, brand }: NavigationProps) { function List({ items, level = 0, crumbs, brand }: ListProps) { return items.map(item => { if (item.children) { + if (item.label.toLowerCase() === 'developers') { + const formattedItems = sortDeveloperMenu(item.children); + return ( + + + + ); + } return ( diff --git a/apps/site/src/content/design-system/get-started/developers/4-eslint/design/eslint-configuration/content.mdoc b/apps/site/src/content/design-system/get-started/developers/eslint-configuration/design/eslint-configuration/content.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/4-eslint/design/eslint-configuration/content.mdoc rename to apps/site/src/content/design-system/get-started/developers/eslint-configuration/design/eslint-configuration/content.mdoc diff --git a/apps/site/src/content/design-system/get-started/developers/4-eslint/index.yaml b/apps/site/src/content/design-system/get-started/developers/eslint-configuration/index.yaml similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/4-eslint/index.yaml rename to apps/site/src/content/design-system/get-started/developers/eslint-configuration/index.yaml diff --git a/apps/site/src/content/design-system/get-started/developers/1-set-up/design/installation/content.mdoc b/apps/site/src/content/design-system/get-started/developers/set-up/design/installation/content.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/1-set-up/design/installation/content.mdoc rename to apps/site/src/content/design-system/get-started/developers/set-up/design/installation/content.mdoc diff --git a/apps/site/src/content/design-system/get-started/developers/1-set-up/design/pre-requisites/content.mdoc b/apps/site/src/content/design-system/get-started/developers/set-up/design/pre-requisites/content.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/1-set-up/design/pre-requisites/content.mdoc rename to apps/site/src/content/design-system/get-started/developers/set-up/design/pre-requisites/content.mdoc diff --git a/apps/site/src/content/design-system/get-started/developers/1-set-up/design/resources/content.mdoc b/apps/site/src/content/design-system/get-started/developers/set-up/design/resources/content.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/1-set-up/design/resources/content.mdoc rename to apps/site/src/content/design-system/get-started/developers/set-up/design/resources/content.mdoc diff --git a/apps/site/src/content/design-system/get-started/developers/1-set-up/index.yaml b/apps/site/src/content/design-system/get-started/developers/set-up/index.yaml similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/1-set-up/index.yaml rename to apps/site/src/content/design-system/get-started/developers/set-up/index.yaml diff --git a/apps/site/src/content/design-system/get-started/developers/5-unit-testing/design/unit-testing/content.mdoc b/apps/site/src/content/design-system/get-started/developers/unit-testing/design/unit-testing/content.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/5-unit-testing/design/unit-testing/content.mdoc rename to apps/site/src/content/design-system/get-started/developers/unit-testing/design/unit-testing/content.mdoc diff --git a/apps/site/src/content/design-system/get-started/developers/5-unit-testing/index.yaml b/apps/site/src/content/design-system/get-started/developers/unit-testing/index.yaml similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/5-unit-testing/index.yaml rename to apps/site/src/content/design-system/get-started/developers/unit-testing/index.yaml diff --git a/apps/site/src/content/design-system/get-started/developers/3-using-brands/design/using-brands/content.mdoc b/apps/site/src/content/design-system/get-started/developers/using-brands/design/using-brands/content.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/3-using-brands/design/using-brands/content.mdoc rename to apps/site/src/content/design-system/get-started/developers/using-brands/design/using-brands/content.mdoc diff --git a/apps/site/src/content/design-system/get-started/developers/3-using-brands/index.yaml b/apps/site/src/content/design-system/get-started/developers/using-brands/index.yaml similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/3-using-brands/index.yaml rename to apps/site/src/content/design-system/get-started/developers/using-brands/index.yaml diff --git a/apps/site/src/content/design-system/get-started/developers/2-using-components/accessibilityDemo.mdoc b/apps/site/src/content/design-system/get-started/developers/using-components/accessibilityDemo.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/2-using-components/accessibilityDemo.mdoc rename to apps/site/src/content/design-system/get-started/developers/using-components/accessibilityDemo.mdoc diff --git a/apps/site/src/content/design-system/get-started/developers/2-using-components/design/using-components/content.mdoc b/apps/site/src/content/design-system/get-started/developers/using-components/design/using-components/content.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/2-using-components/design/using-components/content.mdoc rename to apps/site/src/content/design-system/get-started/developers/using-components/design/using-components/content.mdoc diff --git a/apps/site/src/content/design-system/get-started/developers/2-using-components/index.yaml b/apps/site/src/content/design-system/get-started/developers/using-components/index.yaml similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/2-using-components/index.yaml rename to apps/site/src/content/design-system/get-started/developers/using-components/index.yaml diff --git a/apps/site/src/content/design-system/get-started/developers/2-using-components/relatedArticles.mdoc b/apps/site/src/content/design-system/get-started/developers/using-components/relatedArticles.mdoc similarity index 100% rename from apps/site/src/content/design-system/get-started/developers/2-using-components/relatedArticles.mdoc rename to apps/site/src/content/design-system/get-started/developers/using-components/relatedArticles.mdoc diff --git a/apps/site/src/utils/format.ts b/apps/site/src/utils/format.ts index fc3e81c20..af24be440 100644 --- a/apps/site/src/utils/format.ts +++ b/apps/site/src/utils/format.ts @@ -33,6 +33,18 @@ export function formatNavItems(navList: { name: string; slug: string }[]) { return navItems; } +function orderMenu(menuItems: Item[], order: string[]) { + const orderedMenu: Item[] = []; + order.forEach(item => + menuItems.forEach(menuItem => { + if (item === menuItem.label.toLowerCase()) { + orderedMenu.push(menuItem); + } + }), + ); + return orderedMenu; +} + // This had to be made as a separate function as adding some to formatNavItems too cognitively complex export function sortMenu(menuItems: Item[]) { const topLevelMenuOrder = [ @@ -46,13 +58,11 @@ export function sortMenu(menuItems: Item[]) { 'design tokens', ]; - const orderedMenu: Item[] = []; - topLevelMenuOrder.forEach(item => - menuItems.forEach(menuItem => { - if (item === menuItem.label.toLowerCase()) { - orderedMenu.push(menuItem); - } - }), - ); - return orderedMenu; + return orderMenu(menuItems, topLevelMenuOrder); +} + +export function sortDeveloperMenu(menuItems: Item[]) { + const developersMenuOrder = ['set up', 'using components', 'using brands', 'eslint configuration', 'unit testing']; + + return orderMenu(menuItems, developersMenuOrder); } From 464bef65b377b5fc2076753b25b1b9879092108f Mon Sep 17 00:00:00 2001 From: HZ991 Date: Tue, 1 Oct 2024 10:38:54 +1000 Subject: [PATCH 2/2] added: next:nuke to nuke command (deletes .next folder) --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ddb86bce..117ca9bb4 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,10 @@ "lint": "turbo run lint --no-daemon", "lint:fix": "turbo run lint:fix --no-daemon", "new:package": "node ./helpers/create-package/index.js", - "nuke": "pnpm nuke:node_modules && pnpm nuke:dist", + "nuke": "pnpm nuke:node_modules && pnpm nuke:dist && pnpm nuke:next", "nuke:node_modules": "find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \\;", "nuke:dist": "find . -name 'dist' -type d -prune -print -exec rm -rf '{}' \\;", + "nuke:next": "find . -name '.next' -type d -prune -print -exec rm -rf '{}' \\;", "prepare": "husky install", "test": "turbo run test --filter=./packages/* --no-daemon", "ci:build": "pnpm install --frozen-lockfile && pnpm format && pnpm build && pnpm lint && pnpm check-types && pnpm test",