-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assetbuster: use asset buster for all resources #875
- Loading branch information
Showing
22 changed files
with
180 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import "{{ printf "%s-%s.css" .prefix .light }}" screen and (prefers-color-scheme: light); | ||
@import "{{ printf "%s-%s.css" .prefix .dark }}" screen and (prefers-color-scheme: dark); | ||
{{- $assetBusting := partialCached "assetbusting.hugo" . -}} | ||
@import "{{ printf "%s-%s.css%s" .prefix .light $assetBusting }}" screen and (prefers-color-scheme: light); | ||
@import "{{ printf "%s-%s.css%s" .prefix .dark $assetBusting }}" screen and (prefers-color-scheme: dark); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{- $assetBusting := partialCached "assetbusting.hugo" . -}} | ||
@import "{{ printf "format-print.css%s" $assetBusting }}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{{- $assetBusting := partialCached "assetbusting.hugo" . -}} | ||
/* this file is here for compatiblity with older installations | ||
use theme-relearn-light instead */ | ||
@import "theme-relearn-light.css"; | ||
@import "{{ printf "theme-relearn-light.css%s" $assetBusting }}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
|
||
<span class="github-buttons"></span> | ||
<p>Built with <a href="https://github.com/McShelby/hugo-theme-relearn" title="love"><i class="fas fa-heart"></i></a> by <a href="https://gohugo.io/">Hugo</a></p> | ||
<script> | ||
function githubButtonsScheme(){ | ||
var scheme = 'light'; | ||
var colorPropertyValue = window.getComputedStyle( document.querySelector( '#R-sidebar' ) ).getPropertyValue( 'background-color' ); | ||
var colorValues = colorPropertyValue.match( /\d+/g ).map( function( e ){ return parseInt(e,10); }); | ||
if( colorValues.length === 3 && ((0.2126 * colorValues[0]) + (0.7152 * colorValues[1]) + (0.0722 * colorValues[2]) < 165) ){ | ||
// Luma, https://en.wikipedia.org/wiki/Luma_%28video%29, SMPTE C, Rec. 709 weightings | ||
scheme = 'dark'; | ||
{{- $assetBusting := partialCached "assetbusting.hugo" . }} | ||
<span class="github-buttons"></span> | ||
<p>Built with <a href="https://github.com/McShelby/hugo-theme-relearn" title="love"><i class="fas fa-heart"></i></a> by <a href="https://gohugo.io/">Hugo</a></p> | ||
<script> | ||
function githubButtonsScheme(){ | ||
var scheme = 'light'; | ||
var colorPropertyValue = window.getComputedStyle( document.querySelector( '#R-sidebar' ) ).getPropertyValue( 'background-color' ); | ||
var colorValues = colorPropertyValue.match( /\d+/g ).map( function( e ){ return parseInt(e,10); }); | ||
if( colorValues.length === 3 && ((0.2126 * colorValues[0]) + (0.7152 * colorValues[1]) + (0.0722 * colorValues[2]) < 165) ){ | ||
{{- /* Luma, https://en.wikipedia.org/wiki/Luma_%28video%29, SMPTE C, Rec. 709 weightings */}} | ||
scheme = 'dark'; | ||
} | ||
return scheme; | ||
} | ||
return scheme; | ||
} | ||
function githubButtonsInit(){ | ||
if( !window.githubButtons ){ | ||
// wait for the script to load | ||
setTimeout( githubButtonsInit, 50 ); | ||
return; | ||
} | ||
var scheme = githubButtonsScheme(); | ||
var githubButtonsHTML = ` | ||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn/archive/main.zip" data-color-scheme="${scheme}" data-icon="octicon-cloud-download" aria-label="Download McShelby/hugo-theme-relearn on GitHub">Download</a> | ||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn" data-color-scheme="${scheme}" data-icon="octicon-star" data-show-count="true" aria-label="Star McShelby/hugo-theme-relearn on GitHub">Star</a> | ||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn/fork" data-color-scheme="${scheme}" data-icon="octicon-repo-forked" data-show-count="true" aria-label="Fork McShelby/hugo-theme-relearn on GitHub">Fork</a> | ||
`; | ||
document.querySelector( '.github-buttons' ).innerHTML = githubButtonsHTML; | ||
document.querySelectorAll( '.github-button' ).forEach( function( anchor ){ | ||
anchor.dataset.colorScheme = scheme; | ||
window.githubButtons.render( anchor, function( el ){ | ||
anchor.parentNode.replaceChild( el, anchor ); | ||
function githubButtonsInit(){ | ||
if( !window.githubButtons ){ | ||
{{- /* wait for the script to load */}} | ||
setTimeout( githubButtonsInit, 50 ); | ||
return; | ||
} | ||
var scheme = githubButtonsScheme(); | ||
var githubButtonsHTML = ` | ||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn/archive/main.zip" data-color-scheme="${scheme}" data-icon="octicon-cloud-download" aria-label="Download McShelby/hugo-theme-relearn on GitHub">Download</a> | ||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn" data-color-scheme="${scheme}" data-icon="octicon-star" data-show-count="true" aria-label="Star McShelby/hugo-theme-relearn on GitHub">Star</a> | ||
<a class="github-button" href="https://github.com/McShelby/hugo-theme-relearn/fork" data-color-scheme="${scheme}" data-icon="octicon-repo-forked" data-show-count="true" aria-label="Fork McShelby/hugo-theme-relearn on GitHub">Fork</a> | ||
`; | ||
document.querySelector( '.github-buttons' ).innerHTML = githubButtonsHTML; | ||
document.querySelectorAll( '.github-button' ).forEach( function( anchor ){ | ||
anchor.dataset.colorScheme = scheme; | ||
window.githubButtons.render( anchor, function( el ){ | ||
anchor.parentNode.replaceChild( el, anchor ); | ||
}); | ||
}); | ||
} | ||
document.addEventListener( 'themeVariantLoaded', function( e ){ | ||
{{- /* we have to wait until the CSS class .default-animation has settled and the buttons have loaded to recalculate the scheme again */}} | ||
setTimeout( githubButtonsInit, 400 ); | ||
}); | ||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { | ||
setTimeout( githubButtonsInit, 400 ); | ||
}); | ||
} | ||
document.addEventListener( 'themeVariantLoaded', function( e ){ | ||
// we have to wait until the CSS class .default-animation has settled and the buttons have loaded to recalculate the scheme again | ||
setTimeout( githubButtonsInit, 400 ); | ||
}); | ||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { | ||
setTimeout( githubButtonsInit, 400 ); | ||
}); | ||
</script> | ||
<script async src="{{"js/github-buttons.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script> | ||
</script> | ||
<script async src="{{"js/github-buttons.js" | relURL}}{{ $assetBusting }}"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{- $assetsBuster := "" }} | ||
{{- $assetBusting := not site.Params.disableAssetsBusting }} | ||
{{- if $assetBusting }} | ||
{{- $assetsBuster = printf "?%d" now.Unix }} | ||
{{- end }} | ||
{{- return $assetsBuster }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.