Skip to content

Commit

Permalink
fix: URL rewriting for Academy content
Browse files Browse the repository at this point in the history
  • Loading branch information
thisislawatts committed Dec 28, 2021
1 parent b343caa commit 6ae23e0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/ExternalEmbed/ExternalEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,17 @@ class ExternalEmbed extends React.Component<IProps, IState> {
if ([this.state.targetOrigin].includes(e.origin)) {
// communicate url changes, update navbar
if (e.data && e.data.pathname) {
this.props.history.push(e.data.pathname)
let newPathName = e.data.pathname

/**
* At the moment this component is only used for handling contents within the `/academy`
* section of the site. If we want to use this elsewhere this should lifted outside of the component
* perhaps moved to an emitted event
*/
if (!newPathName.startsWith(`/academy`)) {
newPathName = `/academy${newPathName}`
}
this.props.history.push(newPathName)
}
// communicate a href link clicks, open link in new tab
if (e.data && e.data.linkClick) {
Expand Down

0 comments on commit 6ae23e0

Please sign in to comment.