|
7 | 7 |
|
8 | 8 | <!DOCTYPE html>
|
9 | 9 | <html>
|
| 10 | + <head> |
| 11 | + <script type="text/javascript" charset="utf-8"> |
| 12 | + // const FALLBACK_URL = 'https://opensource.fb.com'; |
| 13 | + const REDIRECT_STYLE = { |
| 14 | + // Redirect completely, appending the path to the newly specified location. |
| 15 | + // This is useful for project renames or moving to a different org. |
| 16 | + FULL: 0, |
| 17 | + // Redirect to the specific location, losing path information |
| 18 | + // This is useful when you just want to capture the audience to known working page. |
| 19 | + SIMPLE: 1, |
| 20 | + // Redirect to the project's 404 page, injecting the original URL. |
| 21 | + FOUROHFOUR_DEFAULT: 2, |
| 22 | + // Redirect to the specified path, replacing ${from} with the original URL. |
| 23 | + FOUROHFOUR_CUSTOM: 3, |
| 24 | + }; |
| 25 | + |
| 26 | + const PROJECTS = { |
| 27 | + live: { |
| 28 | + location: 'https://playtorch.dev/', |
| 29 | + style: REDIRECT_STYLE.FULL, |
| 30 | + }, |
| 31 | + }; |
| 32 | + |
| 33 | + // eg "https://facebook.github.io/flux/docs/overview/" |
| 34 | + const ORIGINAL_URL = window.location.href; |
| 35 | + // eg [ "", "flux", "docs", "overview", "" ] |
| 36 | + const PATH_PARTS = window.location.path.split('/'); |
| 37 | + // eg "flux" |
| 38 | + const PROJECT = PATH_PARTS[1]; |
| 39 | + // eg "docs/overview/" |
| 40 | + const SUBPATH = PATH_PARTS.slice(2).join('/'); |
| 41 | + |
| 42 | + |
| 43 | + // Perform the redirect only for explicitly defined projects. |
| 44 | + // Otherwise show the 404 page below |
| 45 | + if (PROJECTS.hasOwnProperty(PROJECT)) { |
| 46 | + let newUrl = ''; |
| 47 | + let project = PROJECTS[PROJECT]; |
| 48 | + switch (project.style) { |
| 49 | + case REDIRECT_STYLE.FULL: |
| 50 | + newUrl = project.location + SUBPATH; |
| 51 | + break; |
| 52 | + case REDIRECT_STYLE.SIMPLE: |
| 53 | + newUrl = project.location; |
| 54 | + break; |
| 55 | + case REDIRECT_STYLE.FOUROHFOUR_DEFAULT: |
| 56 | + newUrl = project.location + '404.html?from=' + ORIGINAL_URL; |
| 57 | + break; |
| 58 | + case REDIRECT_STYLE.FOUROHFOUR_CUSTOM: |
| 59 | + newUrl = project.location.replace('${from}', ORIGINAL_URL); |
| 60 | + break; |
| 61 | + default: |
| 62 | + newUrl = FALLBACK_URL; |
| 63 | + } |
| 64 | + |
| 65 | + window.location.href = newUrl; |
| 66 | + } |
| 67 | + |
| 68 | + </script> |
| 69 | + </head> |
10 | 70 | <body>
|
11 | 71 | <div style="text-align: center;">
|
12 | 72 | <img src="{{ site.baseurl }}/assets/images/404_sign.png" />
|
|
0 commit comments