From 69d01e73b548faecb32011053b9346a8fad3c725 Mon Sep 17 00:00:00 2001 From: Nicolas Merget Date: Tue, 19 Nov 2024 12:53:19 +0100 Subject: [PATCH] fix: issue with next and previous buttons for patternhub --- showcases/patternhub/data/routes.tsx | 8 +------- .../patternhub/scripts/generate-docs-mdx.js | 16 +++++++++------- .../patternhub/scripts/generate-example-jsx.js | 16 +++++++++------- .../patternhub/scripts/generate-test-table.js | 17 ++++++++++------- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/showcases/patternhub/data/routes.tsx b/showcases/patternhub/data/routes.tsx index de9f193419d..bdaf5800906 100644 --- a/showcases/patternhub/data/routes.tsx +++ b/showcases/patternhub/data/routes.tsx @@ -305,13 +305,7 @@ const fillNavigationRecursive = ( export const getAllNavigationItems = (isBreadcrumb?: boolean) => { const tree: NavigationItem[] = []; fillNavigationRecursive(ROUTES, tree, isBreadcrumb); - return tree.sort((a, b) => { - if ((a.path?.length ?? 0) > (b.path?.length ?? 0)) { - return -1; - } - - return 1; - }); + return tree; }; export const getNavigationList = (path: string) => { diff --git a/showcases/patternhub/scripts/generate-docs-mdx.js b/showcases/patternhub/scripts/generate-docs-mdx.js index 3927d1aed52..c5957acea60 100644 --- a/showcases/patternhub/scripts/generate-docs-mdx.js +++ b/showcases/patternhub/scripts/generate-docs-mdx.js @@ -8,6 +8,7 @@ import getMigrationFile from './get-migration-file.js'; import { getComponentGroup, getComponentName } from './utils.js'; const componentsPath = './pages/components'; +const webTypesPath = './../../output/stencil/dist/web-types.json'; const getRedirectOldFiles = ( importPath @@ -16,13 +17,14 @@ const Fallback = () => ; export default Fallback;`; const generateDocsMdx = async () => { - const webTypes = JSON.parse( - FS.readFileSync( - './../../output/stencil/dist/web-types.json', - 'utf8' - ).toString() - ); - const elements = webTypes?.contributions?.html?.elements; + let elements = []; + if (FS.existsSync(webTypesPath)) { + const webTypes = JSON.parse( + FS.readFileSync(webTypesPath, 'utf8').toString() + ); + elements = webTypes?.contributions?.html?.elements; + } + const components = JSON.parse( FS.readFileSync('./data/components.json', 'utf8').toString() ); diff --git a/showcases/patternhub/scripts/generate-example-jsx.js b/showcases/patternhub/scripts/generate-example-jsx.js index 0603bcec2b3..2a8fe30e947 100644 --- a/showcases/patternhub/scripts/generate-example-jsx.js +++ b/showcases/patternhub/scripts/generate-example-jsx.js @@ -6,15 +6,17 @@ import { } from './utils.js'; const sharedPath = '../shared'; +const webTypesPath = './../../output/stencil/dist/web-types.json'; const generateExampleJSX = () => { - const webTypes = JSON.parse( - FS.readFileSync( - './../../output/stencil/dist/web-types.json', - 'utf8' - ).toString() - ); - const elements = webTypes?.contributions?.html?.elements; + let elements = []; + if (FS.existsSync(webTypesPath)) { + const webTypes = JSON.parse( + FS.readFileSync(webTypesPath, 'utf8').toString() + ); + elements = webTypes?.contributions?.html?.elements; + } + const imports = []; const examples = []; for (const { name } of elements) { diff --git a/showcases/patternhub/scripts/generate-test-table.js b/showcases/patternhub/scripts/generate-test-table.js index 3b6e5ec9d33..b7762420e37 100644 --- a/showcases/patternhub/scripts/generate-test-table.js +++ b/showcases/patternhub/scripts/generate-test-table.js @@ -1,14 +1,17 @@ import FS from 'node:fs'; import { getComponentName } from './utils.js'; +const webTypesPath = './../../output/stencil/dist/web-types.json'; + const generateTestTable = () => { - const webTypes = JSON.parse( - FS.readFileSync( - './../../output/stencil/dist/web-types.json', - 'utf8' - ).toString() - ); - const elements = webTypes?.contributions?.html?.elements; + let elements = []; + if (FS.existsSync(webTypesPath)) { + const webTypes = JSON.parse( + FS.readFileSync(webTypesPath, 'utf8').toString() + ); + elements = webTypes?.contributions?.html?.elements; + } + const accessibilityReview = JSON.parse( FS.readFileSync( './../shared/_accessibility-review.json',