mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
[theme] rename baseUri to relBasePath #813
This commit is contained in:
parent
a3c4d72125
commit
5f40e57d17
4 changed files with 17 additions and 16 deletions
11
layouts/partials/relBasePath.hugo
Normal file
11
layouts/partials/relBasePath.hugo
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{- /* generates an uphill path from the current page to the root of the site */}}
|
||||
{{- $subdir := strings.TrimSuffix (relLangURL "/") (relLangURL "") }}
|
||||
{{- $relBasePath := .RelPermalink }}
|
||||
{{- $relBasePath = replaceRE "/[^/]*$" "" $relBasePath }}
|
||||
{{- $relBasePath = strings.TrimPrefix $subdir $relBasePath }}
|
||||
{{- $relBasePath = replaceRE "/[^/]*" "/.." $relBasePath }}
|
||||
{{- $relBasePath = trim $relBasePath "/" }}
|
||||
{{- if not $relBasePath }}
|
||||
{{- $relBasePath = "." }}
|
||||
{{- end }}
|
||||
{{- return $relBasePath }}
|
|
@ -30,8 +30,8 @@
|
|||
<script src="{{"js/variant.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
|
||||
<script>
|
||||
window.relearn = window.relearn || {};
|
||||
window.relearn.baseUri='{{ partial "toBaseRelURL.hugo" $page | safeJS }}';
|
||||
window.relearn.baseUriFull='{{ replaceRE "/*$" "" .Site.BaseURL | safeJS }}';
|
||||
window.relearn.relBasePath='{{ partial "relBasePath.hugo" $page | safeJS }}';
|
||||
{{- 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 }}
|
||||
window.index_json_url={{ "index.json" | relLangURL }};
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
{{- $subdir := strings.TrimSuffix (relLangURL "/") (relLangURL "") }}
|
||||
{{- $url := .RelPermalink }}
|
||||
{{- $url = replaceRE "/[^/]*$" "" $url }}
|
||||
{{- $rel_url := strings.TrimPrefix $subdir $url }}
|
||||
{{- $rel_url = replaceRE "/[^/]*" "/.." $rel_url }}
|
||||
{{- $rel_url = trim $rel_url "/" }}
|
||||
{{- if not $rel_url }}
|
||||
{{- $rel_url = "." }}
|
||||
{{- end }}
|
||||
{{- return $rel_url }}
|
|
@ -390,11 +390,11 @@ function initOpenapi( update, attrs ){
|
|||
|
||||
}
|
||||
function renderOpenAPI(oc) {
|
||||
var baseUri = window.relearn.baseUri;
|
||||
var relBasePath = window.relearn.relBasePath;
|
||||
var mod = window.relearn.themeVariantModifier;
|
||||
var buster = window.themeUseOpenapi.assetsBuster ? '?' + window.themeUseOpenapi.assetsBuster : '';
|
||||
var print = isPrint || attrs.isPrintPreview ? "PRINT-" : "";
|
||||
var theme = print ? `${baseUri}/css/theme-relearn-light${mod}.css${buster}` : document.querySelector( '#R-variant-style' ).attributes.href.value
|
||||
var theme = print ? `${relBasePath}/css/theme-relearn-light${mod}.css${buster}` : document.querySelector( '#R-variant-style' ).attributes.href.value
|
||||
var swagger_theme = variants.getColorValue( print + 'OPENAPI-theme' );
|
||||
var swagger_code_theme = variants.getColorValue( print + 'OPENAPI-CODE-theme' );
|
||||
|
||||
|
@ -418,8 +418,8 @@ function initOpenapi( update, attrs ){
|
|||
'<head>' +
|
||||
'<link rel="stylesheet" href="' + window.themeUseOpenapi.css + '">' +
|
||||
'<link rel="stylesheet" href="' + theme + '">' +
|
||||
'<link rel="stylesheet" href="' + baseUri + '/css/swagger.css' + buster + '">' +
|
||||
'<link rel="stylesheet" href="' + baseUri + '/css/swagger-' + swagger_theme + '.css' + buster + '">' +
|
||||
'<link rel="stylesheet" href="' + relBasePath + '/css/swagger.css' + buster + '">' +
|
||||
'<link rel="stylesheet" href="' + relBasePath + '/css/swagger-' + swagger_theme + '.css' + buster + '">' +
|
||||
'</head>' +
|
||||
'<body>' +
|
||||
'<a class="relearn-expander" href="" onclick="return relearn_collapse_all()">Collapse all</a>' +
|
||||
|
@ -1538,7 +1538,7 @@ if( window.themeUseMermaid ){
|
|||
|
||||
function useOpenapi( config ){
|
||||
if( config.css && config.cssInProject ){
|
||||
config.css = window.relearn.baseUri + config.css;
|
||||
config.css = window.relearn.relBasePath + config.css;
|
||||
}
|
||||
}
|
||||
if( window.themeUseOpenapi ){
|
||||
|
|
Loading…
Reference in a new issue