When redirecting preserve anchors

This commit is contained in:
Kovid Goyal 2021-07-20 13:51:50 +05:30
parent 624991b9b7
commit d98c2f89aa
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 3 deletions

View File

@ -46,9 +46,9 @@ def remove_markup(text: str) -> str:
def sub(m: Match) -> str: def sub(m: Match) -> str:
if m.group(1) == 'ref': if m.group(1) == 'ref':
return { return {
'layouts': f'{base}/overview.html#layouts', 'layouts': f'{base}/overview/#layouts',
'sessions': f'{base}/overview.html#sessions', 'sessions': f'{base}/overview/#sessions',
'functional': f'{base}/keyboard-protocol.html#functional-key-definitions', 'functional': f'{base}/keyboard-protocol/#functional-key-definitions',
}[m.group(2)] }[m.group(2)]
return str(m.group(2)) return str(m.group(2))

View File

@ -81,7 +81,12 @@ def add_old_redirects(loc: str) -> None:
<head> <head>
<title>Redirecting...</title> <title>Redirecting...</title>
<link rel="canonical" href="{bname}/" /> <link rel="canonical" href="{bname}/" />
<noscript>
<meta http-equiv="refresh" content="0;url={bname}/" /> <meta http-equiv="refresh" content="0;url={bname}/" />
</noscript>
<script type="text/javascript">
window.location.replace('./{bname}/' + window.location.hash);
</script>
</head> </head>
<body> <body>
<p>Redirecting, please wait...</p> <p>Redirecting, please wait...</p>