Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/AmazingRise/hugo-theme-diary.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmazingRise <8315221+AmazingRise@users.noreply.github.com>2022-08-26 07:43:00 +0300
committerAmazingRise <8315221+AmazingRise@users.noreply.github.com>2022-08-26 07:43:00 +0300
commit1adda175206fb128dd1dfe4935215be5bfa93b0b (patch)
tree4c84678a63fc00f16181738eaee97fa1c85ab7f8
parent5017b8bb9533ac5801918d05f67e13a9d6881859 (diff)
Fixed #134 and remove loadCSS.HEADmain
-rw-r--r--layouts/_default/baseof.html11
-rw-r--r--layouts/partials/head.html39
-rw-r--r--static/vendor/js/loadCSS.js79
3 files changed, 40 insertions, 89 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 757b685..5cbe2a2 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -19,6 +19,15 @@
<!-- mobile footer -->
</div>
{{ partial "journal.html" .}}
- <script src="{{"/js/journal.js" | relURL}}"></script>
+ <!-- For compatibility. View https://github.com/AmazingRise/hugo-theme-diary/pull/135 for details.-->
+ {{- $hugoVersion := split (replaceRE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "$1 $2 $3" hugo.Version) " " -}}
+ {{- if and (eq (int (index $hugoVersion 0)) 0) (ge (int (index $hugoVersion 1)) 101) -}}
+ {{- /* no leading slash */ -}}
+ <script src="{{"js/journal.js" | relURL}}"></script>
+ {{- else -}}
+ {{- /* with leading slash */ -}}
+ <script src="{{"/js/journal.js" | relURL}}"></script>
+ {{- end -}}
+
</body>
</html>
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 9a08420..29a50ec 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -31,7 +31,7 @@
{{ template "_internal/google_analytics.html" . }}
{{ end }}
-<link type="text/css" rel="stylesheet" href="{{"/vendor/css/bootstrap.min.css" | relURL}}">
+
{{if .Site.Params.manifest}}
<link rel="manifest" href="{{.Site.Params.manifest}}">
@@ -54,10 +54,25 @@
<link rel="stylesheet" href="{{ $darkmode.RelPermalink }}" integrity="{{ $darkmode.Data.Integrity }}" media="screen">
{{ end }}
-<script src="{{"/vendor/js/loadCSS.js" | relURL}}"></script>
-<script>
- loadCSS("https://fonts.googleapis.com/css?family=Fira+Mono|Material+Icons");
-</script>
+
+<!-- For compatibility. View https://github.com/AmazingRise/hugo-theme-diary/pull/135 for details.-->
+{{- $hugoVersion := split (replaceRE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "$1 $2 $3" hugo.Version) " " -}}
+{{- if and (eq (int (index $hugoVersion 0)) 0) (ge (int (index $hugoVersion 1)) 101) -}}
+ {{- /* no leading slash */ -}}
+ {{ if and (not (.Params.disableToC) ) (.IsPage) }}
+ <script src="{{"js/toc.js" | relURL}}"></script>
+ {{ end }}
+ <link type="text/css" rel="stylesheet" href="{{"vendor/css/bootstrap.min.css" | relURL}}">
+{{- else -}}
+ {{- /* with leading slash */ -}}
+ {{ if and (not (.Params.disableToC) ) (.IsPage) }}
+ <script src="{{"/js/toc.js" | relURL}}"></script>
+ {{ end }}
+ <link type="text/css" rel="stylesheet" href="{{"/vendor/css/bootstrap.min.css" | relURL}}">
+{{- end -}}
+
+<link rel="stylesheet"
+ href="https://fonts.googleapis.com/css?family=Material+Icons">
{{ if .Site.Params.cloudflareToken }}
<!-- Cloudflare Web Analytics -->
@@ -90,14 +105,20 @@
</script>
{{ end }}
-{{ if and (not (.Params.disableToC) ) (.IsPage) }}
- <script src="{{"/js/toc.js" | relURL}}"></script>
-{{ end }}
+
{{ if and ( and ( .Site.Params.enableGitalk ) ( .IsPage ) ) ( or ( not ( isset .Params "comment" ) ) ( eq .Params.comment true ) ) }}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
-<script src="{{"/vendor/js/md5.min.js" | relURL}}"></script>
+<!-- For compatibility. View https://github.com/AmazingRise/hugo-theme-diary/pull/135 for details.-->
+{{- $hugoVersion := split (replaceRE ".*([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "$1 $2 $3" hugo.Version) " " -}}
+{{- if and (eq (int (index $hugoVersion 0)) 0) (ge (int (index $hugoVersion 1)) 101) -}}
+ {{- /* no leading slash */ -}}
+ <script src="{{"vendor/js/md5.min.js" | relURL}}"></script>
+{{- else -}}
+ {{- /* with leading slash */ -}}
+ <script src="{{"/vendor/js/md5.min.js" | relURL}}"></script>
+{{- end -}}
<script>
var gitalk = new Gitalk({
clientID: '{{ .Site.Params.Gitalk.client_id }}',
diff --git a/static/vendor/js/loadCSS.js b/static/vendor/js/loadCSS.js
deleted file mode 100644
index 0ba961a..0000000
--- a/static/vendor/js/loadCSS.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
-(function(w){
- "use strict";
- /* exported loadCSS */
- var loadCSS = function( href, before, media ){
- // Arguments explained:
- // `href` [REQUIRED] is the URL for your CSS file.
- // `before` [OPTIONAL] is the element the script should use as a reference for injecting our stylesheet <link> before
- // By default, loadCSS attempts to inject the link after the last stylesheet or script in the DOM. However, you might desire a more specific location in your document.
- // `media` [OPTIONAL] is the media type or query of the stylesheet. By default it will be 'all'
- var doc = w.document;
- var ss = doc.createElement( "link" );
- var ref;
- if( before ){
- ref = before;
- }
- else {
- var refs = ( doc.body || doc.getElementsByTagName( "head" )[ 0 ] ).childNodes;
- ref = refs[ refs.length - 1];
- }
-
- var sheets = doc.styleSheets;
- ss.rel = "stylesheet";
- ss.href = href;
- // temporarily set media to something inapplicable to ensure it'll fetch without blocking render
- ss.media = "only x";
-
- // wait until body is defined before injecting link. This ensures a non-blocking load in IE11.
- function ready( cb ){
- if( doc.body ){
- return cb();
- }
- setTimeout(function(){
- ready( cb );
- });
- }
- // Inject link
- // Note: the ternary preserves the existing behavior of "before" argument, but we could choose to change the argument to "after" in a later release and standardize on ref.nextSibling for all refs
- // Note: `insertBefore` is used instead of `appendChild`, for safety re: http://www.paulirish.com/2011/surefire-dom-element-insertion/
- ready( function(){
- ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
- });
- // A method (exposed on return object for external use) that mimics onload by polling document.styleSheets until it includes the new sheet.
- var onloadcssdefined = function( cb ){
- var resolvedHref = ss.href;
- var i = sheets.length;
- while( i-- ){
- if( sheets[ i ].href === resolvedHref ){
- return cb();
- }
- }
- setTimeout(function() {
- onloadcssdefined( cb );
- });
- };
-
- function loadCB(){
- if( ss.addEventListener ){
- ss.removeEventListener( "load", loadCB );
- }
- ss.media = media || "all";
- }
-
- // once loaded, set link's media back to `all` so that the stylesheet applies once it loads
- if( ss.addEventListener ){
- ss.addEventListener( "load", loadCB);
- }
- ss.onloadcssdefined = onloadcssdefined;
- onloadcssdefined( loadCB );
- return ss;
- };
- // commonjs
- if( typeof exports !== "undefined" ){
- exports.loadCSS = loadCSS;
- }
- else {
- w.loadCSS = loadCSS;
- }
-}( typeof global !== "undefined" ? global : this )); \ No newline at end of file