doc: keep IDs when redirecting URLs
When redirecting from old-topic.html#some-id to new-topic.html, the ID is ignored. Not sure if it is possible to keep the ID in the meta redirect, but at least in the JavaScript version we should keep it and redirect from old-topic.html#some-id to new-topic.html#some-id. Signed-off-by: Ruth Fuchss <ruth.fuchss@nordicsemi.no>
This commit is contained in:
parent
6a66ae53f2
commit
828d707465
1 changed files with 9 additions and 2 deletions
|
@ -24,12 +24,19 @@ import os.path
|
|||
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
|
||||
REDIRECT_TEMPLATE = """
|
||||
REDIRECT_TEMPLATE = r"""
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; url=$NEWURL" />
|
||||
<script>
|
||||
window.location.href = "$NEWURL"
|
||||
var id=window.location.href.split("#")[1];
|
||||
|
||||
if (id && (/^[a-zA-Z\:\/0-9\_\-\.]+$/.test(id))) {
|
||||
window.location.href = "$NEWURL"+"#"+id;
|
||||
}
|
||||
else {
|
||||
window.location.href = "$NEWURL";
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue