mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-25 22:22:44 +01:00
Override alias template to preserve anchor fragment (#24394)
This PR fixes an annoyance where docs aliases aren't preserving their
anchor fragments.
The refactor included aliases to keep old links from dying, but
currently they redirect without their anchor, which was used _often_ to
jump to sections.
This overrides the alias template with an alternative that preserves the
anchor fragment.
To note, this is just a copy of the [embedded
template](5c7b79cf7f/tpl/tplimpl/embedded/templates/alias.html
),
but defaults to a JS redirect that preserves the anchor, and uses the
meta tag as a fallback for noscript users.
---------
Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
parent
3843252938
commit
bc784a705b
1 changed files with 13 additions and 0 deletions
13
docs/layouts/alias.html
Normal file
13
docs/layouts/alias.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html{{ with site.LanguageCode | default site.Language.Lang }} lang="{{ . }}"{{ end }}>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{ .Permalink }}</title>
|
||||
<link rel="canonical" href="{{ .Permalink }}">
|
||||
<meta name="robots" content="noindex">
|
||||
<noscript><meta http-equiv="refresh" content="0; url={{ .Permalink }}"></noscript>
|
||||
<script>
|
||||
window.location = "{{ .Permalink }}" + window.location.search + window.location.hash;
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
Loading…
Reference in a new issue