mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-05-31 05:54:12 +00:00
menu: make footer area configurable #1059
This commit is contained in:
parent
566c17d000
commit
b89d1e3fb6
33 changed files with 597 additions and 385 deletions
docs/layouts/partials
|
@ -1,5 +1,5 @@
|
|||
<!-- CSS styles are in layouts/partials/custom-header.html -->
|
||||
<a id="R-logo" href="{{ partial "permalink.gotmpl" (dict "to" .Site.Home) }}">
|
||||
{{ partial "shortcodes/image.html" (dict "page" . "url" "/images/logo.svg?border=false&inlinecontent&lightbox=false&shadow=false") }}
|
||||
{{ partial "shortcodes/image.html" (dict "page" . "url" "/images/logo.svg?border=false&inlinecontent&lightbox=false&shadow=false") }}
|
||||
<div class="logo-title">{{ .Site.Params.linkTitle | default .Site.Title }}</div>
|
||||
</a>
|
|
@ -1,46 +1,45 @@
|
|||
|
||||
<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>
|
||||
<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>
|
||||
{{- with resources.Get "/js/github-buttons/github-buttons.js" }}
|
||||
<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;
|
||||
}
|
||||
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 );
|
||||
});
|
||||
</script>
|
||||
<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;
|
||||
}
|
||||
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 );
|
||||
});
|
||||
</script>
|
||||
{{- $assetBusting := partialCached "assetbusting.gotmpl" . }}
|
||||
{{- $minify := not hugo.IsServer }}
|
||||
{{- if and (isset site.Params "minify") (ne site.Params.minify "") }}
|
||||
|
@ -50,5 +49,5 @@
|
|||
{{- if $minify }}
|
||||
{{- $res = $res | minify }}
|
||||
{{- end }}
|
||||
<script async src="{{ $res.RelPermalink }}{{ $assetBusting }}"></script>
|
||||
<script async src="{{ $res.RelPermalink }}{{ $assetBusting }}"></script>
|
||||
{{- end }}
|
Loading…
Add table
Add a link
Reference in a new issue