Skip to content

Commit

Permalink
fix: issue with next and previous buttons for patternhub (#3486)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget authored Nov 21, 2024
1 parent ba25d6d commit 6cbb208
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
10 changes: 9 additions & 1 deletion showcases/patternhub/components/old-routing-fallback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ const OldRoutingFallback = () => {
}

// This is for the old implementation to work with iframes
const allNavigationItems = getAllNavigationItems();
const allNavigationItems = getAllNavigationItems().sort(
(a, b) => {
if ((a.path?.length ?? 0) > (b.path?.length ?? 0)) {
return -1;
}

return 1;
}
);
const foundRoute = allNavigationItems.find((item) =>
item.path?.endsWith(component)
);
Expand Down
8 changes: 1 addition & 7 deletions showcases/patternhub/data/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,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) => {
Expand Down
16 changes: 9 additions & 7 deletions showcases/patternhub/scripts/generate-docs-mdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,13 +17,14 @@ const Fallback = () => <OldRoutingFallback />;
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()
);
Expand Down
16 changes: 9 additions & 7 deletions showcases/patternhub/scripts/generate-example-jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 10 additions & 7 deletions showcases/patternhub/scripts/generate-test-table.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 6cbb208

Please sign in to comment.