Skip to content

Commit

Permalink
Strip extra levels off page url
Browse files Browse the repository at this point in the history
[CORE-708]
  • Loading branch information
RoyEJohnson committed Jan 14, 2025
1 parent 32c9a7d commit d6e8c4b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/components/shell/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ function RedirectToCanonicalDetailsPage() {
);
}

function RedirectToPageWithoutJunk() {
const {name} = useParams();

return <Navigate to={`/${name}`} replace />;
}

function MainRoutes() {
const {Layout} = useLayoutContext();

Expand All @@ -146,7 +152,7 @@ function MainRoutes() {
<Route path="/details/" element={<Navigate to="/subjects" replace />} />
<Route path="/books/:title" element={<RedirectToCanonicalDetailsPage />} />
<Route path="/textbooks/:title" element={<RedirectToCanonicalDetailsPage />} />
<Route path="/subjects-preview/*" element={<ImportedPage name="subjects" />} />
<Route path="/subjects/*" element={<ImportedPage name="subjects" />} />
<Route path="/k12/*" element={<ImportedPage name="k12" />} />
<Route path="/blog/*" element={<ImportedPage name="blog" />} />
<Route path="/webinars/*" element={<ImportedPage name="webinars" />} />
Expand All @@ -158,7 +164,8 @@ function MainRoutes() {
path="/edtech-partner-program"
element={<ImportedPage name="/openstax-ally-technology-partner-program" />}
/>
<Route path="/:name/*" element={<TopLevelPage />} />
<Route path="/:name/:junk" element={<RedirectToPageWithoutJunk />} />
<Route path="/:name" element={<TopLevelPage />} />
<Route element={<h1>Fell through</h1>} />
</Routes>
</Layout>
Expand Down

0 comments on commit d6e8c4b

Please sign in to comment.