Component docs server only lists HTML files
Fix the component docs server to only generate iFrame examples of HTML files,
allowing any helper files (e.g. helper scripts/CSS/imgs/etc) to be placed
alongside the examples without being linked to.
Fixed: 1132846
Change-Id: I9680f001bda4fb2f00eebc275729e66ac62f4189
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2443615
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
diff --git a/scripts/component_server/server.js b/scripts/component_server/server.js
index 187c661..0e7b77c 100644
--- a/scripts/component_server/server.js
+++ b/scripts/component_server/server.js
@@ -83,9 +83,12 @@
async function getExamplesForPath(filePath) {
const componentDirectory = path.join(devtoolsFrontendFolder, 'component_docs', filePath);
- const contents = await fs.promises.readdir(componentDirectory);
+ const allFiles = await fs.promises.readdir(componentDirectory);
+ const htmlExampleFiles = allFiles.filter(file => {
+ return path.extname(file) === '.html';
+ });
- return createComponentIndexFile(filePath, contents);
+ return createComponentIndexFile(filePath, htmlExampleFiles);
}
function respondWithHtml(response, html) {