mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
openapi: there's a small fire buring in hell #804
This commit is contained in:
parent
92a3375ae8
commit
628d6070c0
3 changed files with 13 additions and 11 deletions
|
@ -1,23 +1,26 @@
|
|||
{{- $page := .page }}
|
||||
{{- with $page }}
|
||||
{{- $urlOpenapi := "" }}
|
||||
{{- $relOpenapi := "" }}
|
||||
{{- $cssInProject := false }}
|
||||
{{- if and (isset .Params "customopenapiurl") .Params.customOpenapiURL }}
|
||||
{{- $urlOpenapi = .Params.customOpenapiURL }}
|
||||
{{- $relOpenapi = .Params.customOpenapiURL }}
|
||||
{{- else if and (isset .Site.Params "customopenapiurl") .Site.Params.customOpenapiURL }}
|
||||
{{- $urlOpenapi = .Site.Params.customOpenapiURL }}
|
||||
{{- $relOpenapi = .Site.Params.customOpenapiURL }}
|
||||
{{- else }}
|
||||
{{- $urlOpenapi = "js/swagger-ui/swagger-ui-bundle.js" | relURL }}
|
||||
{{- if not .Site.Params.disableAssetsBusting }}
|
||||
{{- $urlOpenapi = printf "%s?%d" $urlOpenapi now.Unix }}
|
||||
{{- $urlOpenapi = printf "%s%s" ("js/swagger-ui/swagger-ui-bundle.js" | relURL) (cond .Site.Params.disableAssetsBusting "" (printf "?%d" now.Unix)) }}
|
||||
{{- $relOpenapi = printf "%s%s" ("/js/swagger-ui/swagger-ui-bundle.js") (cond .Site.Params.disableAssetsBusting "" (printf "?%d" now.Unix)) }}
|
||||
{{- $cssInProject = true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<script>window.noZensmooth = true;</script>
|
||||
<script src="{{ $urlOpenapi }}" defer></script>
|
||||
{{- $urlOpenapi := replace $urlOpenapi "swagger-ui-bundle" "swagger-ui-standalone-preset" }}
|
||||
<script src="{{ $urlOpenapi }}" defer></script>
|
||||
{{- $urlOpenapi := replace $urlOpenapi "swagger-ui-standalone-preset" "swagger-ui" }}
|
||||
{{- $urlOpenapi := replace $urlOpenapi ".js" ".css" }}
|
||||
{{- $relOpenapi := replace $relOpenapi "swagger-ui-bundle" "swagger-ui" }}
|
||||
{{- $relOpenapi := replace $relOpenapi ".js" ".css" }}
|
||||
<script>
|
||||
window.themeUseOpenapi = { css: {{ $urlOpenapi }}, assetsBuster: {{ cond (not .Site.Params.disableAssetsBusting) now.Unix 0 }} };
|
||||
window.themeUseOpenapi = { css: {{ $relOpenapi }}, cssInProject: {{ $cssInProject | safeJS }}, assetsBuster: {{ cond (not .Site.Params.disableAssetsBusting) now.Unix 0 }} };
|
||||
</script>
|
||||
{{- end }}
|
|
@ -1,8 +1,7 @@
|
|||
{{- $subdir := strings.TrimSuffix (relLangURL "/") (relLangURL "") }}
|
||||
{{- $url := .RelPermalink }}
|
||||
{{- $url = replaceRE "/[^/]*$" "" $url }}
|
||||
{{- $home_url := .Site.Home.RelPermalink }}
|
||||
{{- $home_url = replaceRE "/[^/]*$" "" $home_url }}
|
||||
{{- $rel_url := strings.TrimPrefix $home_url $url }}
|
||||
{{- $rel_url := strings.TrimPrefix $subdir $url }}
|
||||
{{- $rel_url = replaceRE "/[^/]*" "/.." $rel_url }}
|
||||
{{- $rel_url = trim $rel_url "/" }}
|
||||
{{- return $rel_url }}
|
|
@ -1523,7 +1523,7 @@ if( window.themeUseMermaid ){
|
|||
}
|
||||
|
||||
function useOpenapi( config ){
|
||||
if( config.css && config.css.startsWith( '/' ) ){
|
||||
if( config.css && config.cssInProject ){
|
||||
config.css = window.relearn.baseUri + config.css;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue