Skip to content

Commit 8571a30

Browse files
committed
hide library index in sidebar
1 parent 406bc43 commit 8571a30

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

.github/scripts/generate-docs-utils/category/category-generator.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,19 @@ function computeSlug(outputDir, libraryDir) {
312312
* @param {string} label - Category label
313313
* @param {string} description - Category description
314314
* @param {boolean} overwrite - Whether to overwrite existing files (default: false)
315+
* @param {boolean} hideFromSidebar - Whether to hide the index page from sidebar (default: false)
315316
* @returns {boolean} True if file was created/updated, false if skipped
316317
*/
317-
function createCategoryIndexFile(outputDir, relativePath, label, description, overwrite = false) {
318+
function createCategoryIndexFile(outputDir, relativePath, label, description, overwrite = false, hideFromSidebar = false) {
318319
return createIndexFile(
319320
outputDir,
320321
relativePath,
321322
label,
322323
description,
323324
generateLabel,
324325
generateDescription,
325-
overwrite
326+
overwrite,
327+
hideFromSidebar
326328
);
327329
}
328330

@@ -391,7 +393,9 @@ function ensureBaseCategory(libraryDir) {
391393
const description = 'API reference for all Compose modules and facets.';
392394

393395
// Create index.mdx for base library category
394-
createCategoryIndexFile(libraryDir, '', label, description, false);
396+
// Hide from sidebar (sidebar_position: -1) so it doesn't appear as a duplicate
397+
// The category link in _category_.json will still work
398+
createIndexFile(libraryDir, '', label, description, generateLabel, generateDescription, false, true);
395399

396400
const baseCategory = {
397401
label,

.github/scripts/generate-docs-utils/category/index-page-generator.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,17 @@ function getCategoryItems(outputDir, relativePath, generateLabel, generateDescri
108108
* @param {Array} items - Array of items to display
109109
* @returns {string} Generated MDX content
110110
*/
111-
function generateIndexMdxContent(label, description, items) {
111+
function generateIndexMdxContent(label, description, items, hideFromSidebar = false) {
112112
// Escape quotes in label and description for frontmatter
113113
const escapedLabel = label.replace(/"/g, '\\"');
114114
const escapedDescription = description.replace(/"/g, '\\"');
115115

116+
// Add sidebar_class_name: "hidden" to hide from sidebar if requested
117+
const sidebarClass = hideFromSidebar ? '\nsidebar_class_name: "hidden"' : '';
118+
116119
let mdxContent = `---
117120
title: "${escapedLabel}"
118-
description: "${escapedDescription}"
121+
description: "${escapedDescription}"${sidebarClass}
119122
---
120123
121124
import DocCard, { DocCardGrid } from '@site/src/components/docs/DocCard';
@@ -174,7 +177,8 @@ function createCategoryIndexFile(
174177
description,
175178
generateLabel,
176179
generateDescription,
177-
overwrite = false
180+
overwrite = false,
181+
hideFromSidebar = false
178182
) {
179183
const indexFile = path.join(outputDir, 'index.mdx');
180184

@@ -187,7 +191,7 @@ function createCategoryIndexFile(
187191
const items = getCategoryItems(outputDir, relativePath, generateLabel, generateDescription);
188192

189193
// Generate MDX content
190-
const mdxContent = generateIndexMdxContent(label, description, items);
194+
const mdxContent = generateIndexMdxContent(label, description, items, hideFromSidebar);
191195

192196
// Ensure directory exists
193197
fs.mkdirSync(outputDir, { recursive: true });

0 commit comments

Comments
 (0)