From f9b3085d42df65d93f818b9e9f9cc7cd2a519d90 Mon Sep 17 00:00:00 2001 From: David Boyne Date: Wed, 4 Sep 2024 09:48:02 +0100 Subject: [PATCH] chore(docs): adding redirects for play and learn (#996) Co-authored-by: David Boyne --- redirects.ts | 8 ++++++++ src/pages/play.tsx | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/pages/play.tsx diff --git a/redirects.ts b/redirects.ts index 96f95632..17d27caf 100644 --- a/redirects.ts +++ b/redirects.ts @@ -101,5 +101,13 @@ export default [ { to: '/docs/api/category/ui', from: ['/docs/category/ui'] }, { to: '/docs/api/category/util', from: ['/docs/category/util'] }, { to: '/docs/api/standard-library', from: ['/docs/category/standard-library'] }, + + // redirects for wing.learn section + { to: "https://learn.winglang.io/learn", from: ["/learn/"] }, + { to: "https://learn.winglang.io/learn/preflight-inflight", from: ["/learn/preflight-inflight"] }, + { to: "https://learn.winglang.io/learn/bucket", from: ["/learn/bucket"] }, + { to: "https://learn.winglang.io/learn/counter", from: ["/learn/counter"] }, + { to: "https://learn.winglang.io/learn/queue", from: ["/learn/queue"] }, + { to: "https://learn.winglang.io/learn/topic", from: ["/learn/topic"] }, ] diff --git a/src/pages/play.tsx b/src/pages/play.tsx new file mode 100644 index 00000000..39aadd40 --- /dev/null +++ b/src/pages/play.tsx @@ -0,0 +1,18 @@ +import { useEffect } from 'react'; + +// Load the docs by default +export default function Home() { + useEffect(() => { + // Get the query string code + const urlParams = new URLSearchParams(window.location.search); + const code = urlParams.get('code'); + if (code) { + // Redirect to the play page with the code + // @ts-ignore + window.location = `https://play.winglang.io/play?code=${code}`; + return; + } + // @ts-ignore + window.location = 'https://play.winglang.io/play'; + }, []) +} \ No newline at end of file