test(v2): dogfooding: add huge sidebar for testing purposes (#5130)

* dogfoog: add huge sidebar for testing purposes

* Add standalone doc + build-size tracking
This commit is contained in:
Sébastien Lorber 2021-07-08 20:26:55 +02:00 committed by GitHub
parent dc9f104ccc
commit f03479f69e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 6 deletions

View file

@ -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'

View file

@ -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 <DocSidebarItemCategory {...props} />;
case 'link':
default:
@ -104,10 +108,6 @@ function DocSidebarItemCategory({
}
}, [isActive, wasActive, collapsed]);
if (items.length === 0) {
return null;
}
return (
<li
className={clsx('menu__list-item', {

View file

@ -124,6 +124,7 @@ const isVersioningDisabled = !!process.env.DISABLE_VERSIONING || isI18nStaging;
// Using a symlinked folder as source, test against https://github.com/facebook/docusaurus/issues/3272
path: 'dogfooding/docs-tests-symlink',
routeBasePath: 'docs-tests',
sidebarPath: 'dogfooding/docs-tests-sidebars.js',
},
],

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
module.exports = {
sidebar: [
{
type: 'doc',
id: 'index',
label: 'Index',
},
{
type: 'category',
label: 'Huge sidebar category',
items: generateHugeSidebarItems(4),
},
],
};
function generateHugeSidebarItems() {
const maxLevel = 4;
const linksCount = 5;
const categoriesCount = 5;
function generateRecursive(maxLevel, currentLevel = 0) {
if (currentLevel === maxLevel) {
return [];
}
const linkItems = [...Array(linksCount).keys()].map((index) => ({
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);
}

View file

@ -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