Skip to content

Commit dbd56c0

Browse files
mrosvikBarsnes
andauthored
docs: split utilities sidebar into react section (#4869)
Co-authored-by: Barsnes <tobias.barsnes@digdir.no>
1 parent 47d1a43 commit dbd56c0

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

apps/www/app/layouts/components/layout.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,21 @@ export const loader = async ({
4646

4747
// Get all folders in components-docs/{lang}
4848
const docsFolders = getFoldersInContentDir(join('components-docs', lang));
49+
const reactUtilities = new Set([
50+
'roving-focus',
51+
'use-checkbox-group',
52+
'use-pagination',
53+
'use-radio-group',
54+
'use-synchronized-animation',
55+
]);
4956

5057
// Process each folder as a category
5158
for (const folder of docsFolders) {
5259
const categoryKey = folder === 'get-started' ? 'getStarted' : folder;
5360
cats[categoryKey] = [];
61+
if (folder === 'utilities') {
62+
cats.utilitiesReact = [];
63+
}
5464

5565
// Get all files in this folder
5666
const filesInFolder = getFilesFromContentDir(
@@ -62,18 +72,26 @@ export const loader = async ({
6272
join('components-docs', lang, folder, `${file.relativePath}`),
6373
);
6474
const result = await generateFromMdx(fileContent);
75+
const slug = file.relativePath.replace('.mdx', '');
76+
const utilityCategory =
77+
folder === 'utilities' && reactUtilities.has(slug)
78+
? 'utilitiesReact'
79+
: categoryKey;
6580

66-
cats[categoryKey].push({
81+
cats[utilityCategory].push({
6782
title:
6883
result.frontmatter.sidebar_title ||
6984
file.relativePath.replace('.mdx', ''),
70-
url: `/${lang}/components/${folder}/${file.relativePath.replace('.mdx', '')}`,
85+
url: `/${lang}/components/${folder}/${slug}`,
7186
order: parseInt(result.frontmatter.order, 10) || 9999,
7287
});
7388
}
7489

7590
// Sort items within the category by order
7691
cats[categoryKey].sort((a, b) => (a.order || 9999) - (b.order || 9999));
92+
if (folder === 'utilities') {
93+
cats.utilitiesReact.sort((a, b) => (a.order || 9999) - (b.order || 9999));
94+
}
7795
}
7896

7997
/* read all folders in content/components */

apps/www/app/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export default {
9494
getStarted: 'Getting Started',
9595
typography: 'Typography',
9696
utilities: 'Utilities',
97+
utilitiesReact: 'Utilities for React',
9798
},
9899
items: {
99100
Introduction: 'Introduction',

apps/www/app/locales/no.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default {
9393
getStarted: 'Kom i gang',
9494
typography: 'Typografi',
9595
utilities: 'Hjelpeverktøy',
96+
utilitiesReact: 'Hjelpeverktøy for React',
9697
},
9798
items: {
9899
Introduction: 'Introduksjon',

0 commit comments

Comments
 (0)