Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Commit

Permalink
Redirect all pages to the new website
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimrocha committed Dec 15, 2022
1 parent a2396c4 commit 774c05b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
2 changes: 1 addition & 1 deletion site/content/docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
title: Documentation
linkTitle: Documentation
children_are_versions: true
layout: redirect
sidebar:
skip: true
weight: 10
aliases:
- /docs/latest
cascade:
layout: redirect
type: docs
hero:
merge: true
Expand Down
29 changes: 21 additions & 8 deletions site/themes/docs/layouts/docs/redirect.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
<!DOCTYPE html>
<html>
<head>
{{- $redirectURL := "" -}}
{{- if .Site.Params.docs.external_docs -}}
{{- $docs := default (dict "name" "") (index .Site.Params.docs.external_docs 0) -}}
{{- $redirectURL = default "" (print .Site.BaseURL "/docs/" $docs.name) -}}
{{- end -}}
{{- if $redirectURL -}}
{{- $redirectURL := default "" .Site.Params.redirect_url -}}
<noscript>
<meta http-equiv="refresh" content="0; url='{{ $redirectURL }}'" />
</noscript>
{{- if $redirectURL -}}
<script>
window.location.replace("{{ $redirectURL }}" + window.location.hash);
let redirectURL = '{{ $redirectURL }}';
if (redirectURL[redirectURL.length - 1] !== '/') {
redirectURL += '/';
}
const u = window.location.href;
const ghSplit = u.split('github.io/')
let repoName = '';
if (ghSplit.length > 1) {
repoName = ghSplit[1].split('/')[0] + '/';
}
let origin = window.location.origin;
if (origin[origin.length - 1] === '/') {
origin = origin.slice(0, -1);
}
const finalRedirect = u.replace(origin + '/' + repoName, redirectURL);
if ((new URL(finalRedirect)).origin !== window.location.origin) {
window.location.replace(finalRedirect);
}
</script>
{{- end -}}
</head>
Expand All @@ -22,4 +35,4 @@
<p>No redirect found. You either need to set up docs or content (edit content/_index.md).</p>
{{- end -}}
</body>
</html>
</html>
33 changes: 20 additions & 13 deletions site/themes/docs/layouts/redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@
<html>
<head>
{{- $redirectURL := default "" .Site.Params.redirect_url -}}
{{- if .Site.Params.docs.external_docs -}}
{{- $default_docs := index .Site.Params.docs.external_docs 0 -}}
{{- if $default_docs -}}
{{ $default_docs = print "/docs/" $default_docs.name }}
{{- end -}}
{{- $redirectURL = default "" $default_docs -}}
{{- end -}}
{{- if $redirectURL -}}
{{- if not (hasPrefix $redirectURL "http") -}}
{{- $redirectURL = print .Site.BaseURL $redirectURL -}}
{{- end -}}
<noscript>
<meta http-equiv="refresh" content="0; url='{{ $redirectURL }}'" />
</noscript>
{{- if $redirectURL -}}
<script>
window.location.replace("{{ $redirectURL }}" + window.location.hash);
let redirectURL = '{{ $redirectURL }}';
if (redirectURL[redirectURL.length - 1] !== '/') {
redirectURL += '/';
}
const u = window.location.href;
const ghSplit = u.split('github.io/')
let repoName = '';
if (ghSplit.length > 1) {
repoName = ghSplit[1].split('/')[0];
}
let origin = window.location.origin;
if (origin[origin.length - 1] === '/') {
origin = origin.slice(0, -1);
}
const finalRedirect = u.replace(origin + '/' + repoName, redirectURL);
if ((new URL(finalRedirect)).origin !== window.location.origin) {
window.location.replace(finalRedirect);
}
</script>
{{- end -}}
</head>
Expand All @@ -28,4 +35,4 @@
<p>No redirect found. You either need to set up docs or content (edit content/_index.md).</p>
{{- end -}}
</body>
</html>
</html>

0 comments on commit 774c05b

Please sign in to comment.