Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/docs/api/appkit-ui/data/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Data components",
"position": 3
}
4 changes: 4 additions & 0 deletions docs/docs/api/appkit-ui/ui/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "UI components",
"position": 2
}
26 changes: 19 additions & 7 deletions docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,25 @@ const config: Config = {
...args
}) {
const sidebarItems = await defaultSidebarItemsGenerator(args);
// exclude API reference - this category is handled manually in sidebars.ts
return sidebarItems.filter(
(item) =>
item.type !== "category" ||
item.link?.type !== "doc" ||
item.link.id !== "api/index",
);

return sidebarItems.filter((item) => {
// Exclude API reference category - handled manually in sidebars.ts
if (
item.type === "category" &&
item.link?.type === "doc" &&
item.link.id === "api/index"
) {
return false;
}

// Exclude api/appkit-ui/index - automatically used as category link in sidebars.ts
// Explicit dirName in sidebars.ts bypasses automatic exclusion
if (item.type === "doc" && item.id === "api/appkit-ui/index") {
return false;
}

return true;
});
},
},
theme: {
Expand Down
20 changes: 2 additions & 18 deletions docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,8 @@ const sidebars: SidebarsConfig = {
},
items: [
{
type: "category",
label: "UI components",
items: [
{
type: "autogenerated",
dirName: "api/appkit-ui/ui",
},
],
},
{
type: "category",
label: "Data components",
items: [
{
type: "autogenerated",
dirName: "api/appkit-ui/data",
},
],
type: "autogenerated",
dirName: "api/appkit-ui",
},
],
},
Expand Down
30 changes: 29 additions & 1 deletion tools/generate-component-mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const FILE_EXTENSIONS = {
EXAMPLE: ".example.tsx",
TEST_PATTERN: ".test.",
INDEX: "/index.tsx",
CATEGORY_CONFIG: "_category_.json",
} as const;

const COMPONENT_PATTERNS = {
Expand Down Expand Up @@ -557,7 +558,8 @@ function main() {
// Create output directory if it doesn't exist
fs.mkdirSync(outputDir, { recursive: true });

// Delete only subdirectories (preserve files like index.md)
// Delete only subdirectories (preserve root-level files)
// This preserves files like _index.md (category link) and styling.md (manual docs)
if (fs.existsSync(outputDir)) {
const entries = fs.readdirSync(outputDir, { withFileTypes: true });
for (const entry of entries) {
Expand All @@ -576,6 +578,32 @@ function main() {
fs.mkdirSync(dataOutputDir, { recursive: true });
fs.mkdirSync(uiOutputDir, { recursive: true });

// Create _category_.json files for proper sidebar labels
fs.writeFileSync(
path.join(uiOutputDir, FILE_EXTENSIONS.CATEGORY_CONFIG),
`${JSON.stringify(
{
label: "UI components",
position: 2,
},
null,
2,
)}\n`,
MARKDOWN.FILE_ENCODING,
);
fs.writeFileSync(
path.join(dataOutputDir, FILE_EXTENSIONS.CATEGORY_CONFIG),
`${JSON.stringify(
{
label: "Data components",
position: 3,
},
null,
2,
)}\n`,
MARKDOWN.FILE_ENCODING,
);

let count = 0;

const fileNameCounts = new Map<string, number>();
Expand Down