mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
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:
parent
dc9f104ccc
commit
f03479f69e
5 changed files with 59 additions and 6 deletions
2
.github/workflows/v2-build-size-report.yml
vendored
2
.github/workflows/v2-build-size-report.yml
vendored
|
@ -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'
|
||||
|
|
|
@ -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', {
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
|
||||
|
|
49
website/dogfooding/docs-tests-sidebars.js
Normal file
49
website/dogfooding/docs-tests-sidebars.js
Normal 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);
|
||||
}
|
3
website/dogfooding/docs-tests/standalone.md
Normal file
3
website/dogfooding/docs-tests/standalone.md
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue