Skip to content

Commit

Permalink
docs: version URL and image support baseURL (#5037)
Browse files Browse the repository at this point in the history
* baseURL

Signed-off-by: zirain <[email protected]>

* image support baseURL

Signed-off-by: zirain <[email protected]>

* fix

Signed-off-by: zirain <[email protected]>

---------

Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain authored Jan 14, 2025
1 parent 8e24e27 commit 213f2e6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions site/hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ id = "G-DXJEH1ZRXX"
block = true
[markup.goldmark.renderer]
unsafe = true
[markup.goldmark.renderHooks]
[markup.goldmark.renderHooks.image]
enableDefault = true
[markup.highlight]
# See a complete list of available styles at https://xyproto.github.io/splash/docs/all.html
style = "tango"
Expand Down
10 changes: 10 additions & 0 deletions site/layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{ $baseURL := site.BaseURL }}
{{ $safeURL := .Destination | safeURL }}
{{ if and (ne $baseURL "/") (not (or (strings.HasPrefix $safeURL "https://") (strings.HasPrefix $safeURL "http://") (strings.HasPrefix $safeURL "mailto:"))) }}
{{ $safeURL = printf "%s%s" $baseURL $safeURL }}
{{ end }}
<img src="{{ $safeURL }}"
{{- with .PlainText }} alt="{{ . }}"{{ end -}}
{{- with .Title }} title="{{ . }}"{{ end -}}
>
{{- /* chomp trailing newline */ -}}
19 changes: 19 additions & 0 deletions site/layouts/partials/navbar-version-selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{ $baseURL := .Site.BaseURL }}
<div class="dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{- .Site.Params.version_menu -}}
</a>
<ul class="dropdown-menu">
{{ $path := "" -}}
{{ if .Site.Params.version_menu_pagelinks -}}
{{ $path = .Page.RelPermalink -}}
{{ end -}}
{{ range .Site.Params.versions -}}
{{ if ne $baseURL "/" }}
<li><a class="dropdown-item" href="{{ $baseURL }}{{ .url }}{{ $path }}">{{ .version }}</a></li>
{{ else }}
<li><a class="dropdown-item" href="{{ .url }}{{ $path }}">{{ .version }}</a></li>
{{ end }}
{{ end -}}
</ul>
</div>

0 comments on commit 213f2e6

Please sign in to comment.