openapi: next try #804

Hugo's making me angry
This commit is contained in:
Sören Weber 2024-03-16 18:40:06 +01:00
parent 4da0ebbaf8
commit d0cc34396d
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
5 changed files with 14 additions and 4 deletions

View file

@ -14,7 +14,7 @@
<title>{{ $title }}</title> <title>{{ $title }}</title>
<base href="{{ .Site.BaseURL }}"> <base href="{{ .Site.BaseURL }}">
{{- partialCached "favicon.html" . }} {{- partialCached "favicon.html" . }}
{{- partialCached "stylesheet.html" (dict "page" . "outputFormat" $outputFormat) $outputFormat }} {{- partial "stylesheet.html" (dict "page" . "outputFormat" $outputFormat) }}
<style> <style>
p { p {
text-align: center text-align: center

View file

@ -66,7 +66,7 @@
{{- end }} {{- end }}
{{- partialCached "favicon.html" . }} {{- partialCached "favicon.html" . }}
{{- partialCached "stylesheet.html" (dict "page" . "outputFormat" $outputFormat) $outputFormat }} {{- partial "stylesheet.html" (dict "page" . "outputFormat" $outputFormat) }}
{{- partial "dependencies.html" (dict "page" . "location" "header" "outputFormat" $outputFormat) }} {{- partial "dependencies.html" (dict "page" . "location" "header" "outputFormat" $outputFormat) }}
{{- partial "custom-header.html" . }} {{- partial "custom-header.html" . }}
</head> </head>

View file

@ -30,8 +30,8 @@
<script src="{{"js/variant.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script> <script src="{{"js/variant.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
<script> <script>
window.relearn = window.relearn || {}; window.relearn = window.relearn || {};
window.relearn.baseUri='{{ "css/theme.css" | relURL | safeJS }}'.replace(/(.*)css\/theme\.css/, '$1').replace(/\/*$/, ''); window.relearn.baseUri='{{ partial "toBaseRelURL.hugo" $page | safeJS }}';
window.relearn.baseUriFull='{{ .Site.BaseURL | safeJS }}/'.replace(/\/*$/, ''); window.relearn.baseUriFull='{{ replaceRE "/*$" "" .Site.BaseURL | safeJS }}';
{{- with .Site.Home.OutputFormats.Get "json" }} {{- with .Site.Home.OutputFormats.Get "json" }}
{{- warnf "%q: DEPRECATED usage of 'json' output format found, use 'search' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/customization#activate-search" $page.File.Filename }} {{- warnf "%q: DEPRECATED usage of 'json' output format found, use 'search' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/customization#activate-search" $page.File.Filename }}
window.index_json_url={{ "index.json" | relLangURL }}; window.index_json_url={{ "index.json" | relLangURL }};

View file

@ -0,0 +1,7 @@
{{- $url := partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
{{- $url = path.Clean $url }}
{{- $url = replaceRE "/[^/]*$" "" $url }}
{{- $url = replaceRE "/[^/]*" "/.." $url }}
{{- $url = replaceRE "^/" "" $url }}
{{- $url = replaceRE "/$" "" $url }}
{{- return $url }}

View file

@ -1523,6 +1523,9 @@ if( window.themeUseMermaid ){
} }
function useOpenapi( config ){ function useOpenapi( config ){
if( config.css && config.css.startsWith( '/' ) ){
config.css = window.relearn.baseUri + config.css;
}
} }
if( window.themeUseOpenapi ){ if( window.themeUseOpenapi ){
useOpenapi( window.themeUseOpenapi ); useOpenapi( window.themeUseOpenapi );