Skip to content
Merged
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
12 changes: 7 additions & 5 deletions examples/scripts/build-metadata.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { parseConfig } from '../utils/utils.mjs';
* @type {{
* path: string,
* categoryKebab: string,
* exampleNameKebab: string
* exampleNameKebab: string,
* hidden: boolean
* }[]}
*/
const exampleMetaData = [];
Expand Down Expand Up @@ -55,15 +56,16 @@ const main = () => {
const exampleNameKebab = toKebabCase(exampleName);

const config = parseConfig(fs.readFileSync(examplePath, 'utf-8'));
if (config.HIDDEN && process.env.NODE_ENV !== 'development') {
console.info(`skipping hidden ${categoryKebab}/${exampleNameKebab}`);
return;
const hidden = !!config.HIDDEN;
if (hidden) {
console.info(`hidden (not listed in sidebar): ${categoryKebab}/${exampleNameKebab}`);
}

exampleMetaData.push({
path: categoryPath,
categoryKebab,
exampleNameKebab
exampleNameKebab,
hidden
});
});
});
Expand Down
9 changes: 8 additions & 1 deletion examples/src/app/components/Sidebar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ function getDefaultExampleFiles() {
/** @type {Record<string, { examples: Record<string, string> }>} */
const categories = {};
for (let i = 0; i < exampleMetaData.length; i++) {
const { categoryKebab, exampleNameKebab } = exampleMetaData[i];
const { categoryKebab, exampleNameKebab, hidden } = exampleMetaData[i];

// hidden examples are always built and reachable via URL, but are only listed in the
// sidebar during development (`npm run develop`), not in production builds (`npm run build`)
if (hidden && process.env.NODE_ENV !== 'development') {
continue;
}

if (!categories[categoryKebab]) {
categories[categoryKebab] = { examples: {} };
}
Expand Down
2 changes: 1 addition & 1 deletion examples/utils/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const isModuleWithExternalDependencies = (content) => {
/**
* @typedef {object} ExampleConfig
* @property {string} [DESCRIPTION] - The example description.
* @property {boolean} [HIDDEN] - The example is hidden on production.
* @property {boolean} [HIDDEN] - The example is hidden from the sidebar list in production builds (`npm run build`). It is still built and reachable via its URL. In development (`npm run develop`) it is still shown in the sidebar.
* @property {'development' | 'performance' | 'debug'} [ENGINE] - The engine type.
* @property {boolean} [NO_DEVICE_SELECTOR] - No device selector.
* @property {boolean} [NO_MINISTATS] - No ministats.
Expand Down