Skip to content

Commit

Permalink
Fix relative redirect for old socketslack location (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec authored Nov 25, 2022
1 parent c273597 commit 59a9417
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/installation/socketslack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ sidebar_position: -1
sidebar_class_name: hidden
---

{/* This file simply redirects old "socketslack" route to the "slack" one, as we deprecated the legacy Slack integration. */}
Redirecting to the new location of Slack installation... If you are not redirected in a few seconds, please click [here](./slack/index.md).

import { Redirect } from "@docusaurus/router";
import { RelativeRedirect } from "@site/src/components/RelativeRedirect";

{" "}

<Redirect to="./slack" />;
<RelativeRedirect to="slack" />
17 changes: 17 additions & 0 deletions src/components/RelativeRedirect/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { FC } from "react";
import { Redirect, useLocation } from "@docusaurus/router";

export interface RelativeRedirectProps {
to: string;
}

export const RelativeRedirect: FC<RelativeRedirectProps> = ({ to }) => {
const { pathname } = useLocation();

let location = to;
if (pathname.endsWith("/")) {
location = `../${to}`;
}

return <Redirect to={location} />;
};

0 comments on commit 59a9417

Please sign in to comment.