diff --git a/.github/workflows/v2-build-size-report.yml b/.github/workflows/v2-build-size-report.yml index ba972a000e..d24d65f1bf 100644 --- a/.github/workflows/v2-build-size-report.yml +++ b/.github/workflows/v2-build-size-report.yml @@ -26,7 +26,7 @@ jobs: with: repo-token: '${{ secrets.GITHUB_TOKEN }}' build-script: 'build:v2:en' - pattern: '{website/build/assets/js/main*js,website/build/assets/css/styles*css,website/build/index.html,website/build/blog/**/introducing-docusaurus/*,website/build/docs/introduction/index.html,website/.docusaurus/globalData.json}' + pattern: '{website/build/assets/js/main*js,website/build/assets/css/styles*css,website/.docusaurus/globalData.json,website/build/index.html,website/build/blog/**/introducing-docusaurus/*,website/build/docs/index.html,website/build/docs/introduction/index.html,website/build/docs-tests/index.html,website/build/docs-tests/standalone/index.html}' strip-hash: '\.([^;]\w{7})\.' minimum-change-threshold: 30 compression: 'none' diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx index ae96ae86b5..01c893bca7 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocSidebar/index.tsx @@ -58,9 +58,13 @@ const DocSidebarItems = memo(function DocSidebarItems({ )); }); -function DocSidebarItem(props): JSX.Element { +function DocSidebarItem(props): JSX.Element | null { switch (props.item.type) { case 'category': + // Never render empty categories + if (props.item.items.length === 0) { + return null; + } return ; case 'link': default: @@ -104,10 +108,6 @@ function DocSidebarItemCategory({ } }, [isActive, wasActive, collapsed]); - if (items.length === 0) { - return null; - } - return (
  • ({ + type: 'link', + href: '/', + label: `Link ${index} (level ${currentLevel + 1})`, + })); + + const categoryItems = [...Array(categoriesCount).keys()].map((index) => ({ + type: 'category', + label: `Category ${index} (level ${currentLevel + 1})`, + items: generateRecursive(maxLevel, currentLevel + 1), + })); + + return [...linkItems, ...categoryItems]; + } + + return generateRecursive(maxLevel); +} diff --git a/website/dogfooding/docs-tests/standalone.md b/website/dogfooding/docs-tests/standalone.md new file mode 100644 index 0000000000..5103ded42c --- /dev/null +++ b/website/dogfooding/docs-tests/standalone.md @@ -0,0 +1,3 @@ +# Standalone doc + +This doc is not in any sidebar, on purpose, to measure the build size impact of the huge sidebar