mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 16:28:59 +00:00
Fetch redirects based on the current URL. (#11450)
* Fetch redirects based on the current URL. * Apply suggestions from code review --------- Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
This commit is contained in:
co-authored by
Hugo Locurcio
parent
b197efa329
commit
77a966c622
@@ -35,8 +35,12 @@ Page not found
|
|||||||
|
|
||||||
// Check for redirects if on a currently invalid page.
|
// Check for redirects if on a currently invalid page.
|
||||||
// This is done in JavaScript, as we exceed Read the Docs' limit for the amount of redirects configurable.
|
// This is done in JavaScript, as we exceed Read the Docs' limit for the amount of redirects configurable.
|
||||||
// When testing this feature on a local web server, replace the URL below with just `/_static/redirects.csv`.
|
|
||||||
fetch("/en/latest/_static/redirects.csv")
|
const currentPathSegments = window.location.pathname.split('/').filter(segment => segment !== '');
|
||||||
|
// Use the base path (e.g. "/en/latest") when available.
|
||||||
|
const currentBasePath = (currentPathSegments.length >= 2) ? ("/" + currentPathSegments.slice(0, 2).join("/")) : "/";
|
||||||
|
|
||||||
|
fetch(currentBasePath + "/_static/redirects.csv")
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(csvText => {
|
.then(csvText => {
|
||||||
const lines = csvText.trim().split('\n');
|
const lines = csvText.trim().split('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user