Skip to content

Commit 705ad05

Browse files
Fix: Added code fix for stop 2950 ticket- navigation issue for extra … (#2830)
* Fix: Added code fix for stop 2950 ticket- navigation issue for extra 'slug' property in TOC schema * upgrade version of elements-dev-portal from 3.0.6 to 3.0.7 * The updated routing structure enables nested routes under the root path, allowing dynamic matching for both branch-specific and general project nodes. * The destructuring of route parameters using useParams efficiently extracts branchSlug and the wildcard nodeSlug for precise contextual rendering within nested components.
1 parent 81f0876 commit 705ad05

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/elements-dev-portal/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stoplight/elements-dev-portal",
3-
"version": "3.0.6",
3+
"version": "3.0.7",
44
"description": "UI components for composing beautiful developer documentation.",
55
"keywords": [],
66
"sideEffects": [

packages/elements-dev-portal/src/containers/StoplightProject.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ export interface StoplightProjectProps extends RoutingProps {
9898
}
9999

100100
const StoplightProjectImpl: React.FC<StoplightProjectProps> = ({ projectId, collapseTableOfContents = false }) => {
101-
const { branchSlug: encodedBranchSlug = '', nodeSlug = '' } = useParams<{ branchSlug?: string; nodeSlug: string }>();
101+
const { branchSlug: encodedBranchSlug = '', '*': nodeSlug = '' } = useParams<{
102+
branchSlug?: string;
103+
'*': string;
104+
}>();
102105
const branchSlug = decodeURIComponent(encodedBranchSlug);
103106
const navigate = useNavigate();
104107

@@ -110,7 +113,7 @@ const StoplightProjectImpl: React.FC<StoplightProjectProps> = ({ projectId, coll
110113
isError,
111114
error: nodeError,
112115
} = useGetNodeContent({
113-
nodeSlug,
116+
nodeSlug: nodeSlug ?? '',
114117
projectId,
115118
branchSlug,
116119
});
@@ -171,7 +174,7 @@ const ProjectNode: React.FC<StoplightProjectProps> = ({
171174
tryItCredentialsPolicy,
172175
tryItCorsProxy,
173176
}) => {
174-
const { branchSlug: encodedBranchSlug = '', nodeSlug = '' } = useParams<{ branchSlug?: string; nodeSlug: string }>();
177+
const { branchSlug: encodedBranchSlug = '', '*': nodeSlug = '' } = useParams<{ branchSlug?: string; '*': string }>();
175178
const branchSlug = decodeURIComponent(encodedBranchSlug);
176179
const [isLoadingNode, isTocFetched, isError, nodeError, node] = useOutletContext<any>();
177180

@@ -233,11 +236,8 @@ const StoplightProjectRouter = ({
233236
const InternalRoutes = () => (
234237
<Routes>
235238
<Route path="/" element={<StoplightProjectImpl {...props} />}>
236-
<Route path="/branches/:branchSlug/:nodeSlug/*" element={<ProjectNode {...props} />} />
237-
238-
<Route path="/:nodeSlug/*" element={<ProjectNode {...props} />} />
239-
240-
<Route element={<ProjectNode {...props} />} />
239+
<Route path="/branches/:branchSlug/*" element={<ProjectNode {...props} />} />
240+
<Route path="/*" element={<ProjectNode {...props} />} />
241241
</Route>
242242
</Routes>
243243
);

0 commit comments

Comments
 (0)