support weight front-matter, meta color change dynamically,
This commit is contained in:
parent
f933e10cd3
commit
8575c09630
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="summary__container" data-display="block">
|
<div class="summary__container" data-display="block">
|
||||||
{{ $paginator := .Paginate (where .Pages "Type" .Type) }}
|
{{ $paginator := .Paginate (where .Pages "Type" .Type).ByWeight }}
|
||||||
{{ range $paginator.Pages }}
|
{{ range $paginator.Pages }}
|
||||||
{{ .Render "summary" }}
|
{{ .Render "summary" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="summary__container" data-display="block">
|
<div class="summary__container" data-display="block">
|
||||||
{{ range .Paginator.Pages }}
|
{{ range .Paginator.Pages.ByWeight }}
|
||||||
{{ .Render "summary" }}
|
{{ .Render "summary" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ partial "pagination/pagination" . }}
|
{{ partial "pagination/pagination" . }}
|
||||||
|
|
|
@ -439,21 +439,36 @@
|
||||||
var selectThemeItemElem = document.querySelectorAll('.select-theme__item');
|
var selectThemeItemElem = document.querySelectorAll('.select-theme__item');
|
||||||
|
|
||||||
var setMetaColor = function(themeColor) {
|
var setMetaColor = function(themeColor) {
|
||||||
|
var metaMsapplicationTileColor = document.getElementsByName('msapplication-TileColor')[0];
|
||||||
|
var metaThemeColor = document.getElementsByName('theme-color')[0];
|
||||||
|
var metaMsapplicationNavbuttonColor = document.getElementsByName('msapplication-navbutton-color')[0];
|
||||||
|
var metaAppleMobileWebAappStatusBarStyle = document.getElementsByName('apple-mobile-web-app-status-bar-style')[0];
|
||||||
|
|
||||||
if (themeColor.includes('dark')) {
|
if (themeColor.includes('dark')) {
|
||||||
{{ $.Scratch.Set "themeTitleColor" "#fcfcfa" }}
|
metaMsapplicationTileColor.setAttribute('content', '#fcfcfa');
|
||||||
{{ $.Scratch.Set "themeNavbarColor" "#403E41" }}
|
metaThemeColor.setAttribute('content', '#403E41');
|
||||||
|
metaMsapplicationNavbuttonColor.setAttribute('content', '#403E41');
|
||||||
|
metaAppleMobileWebAappStatusBarStyle.setAttribute('content', '#403E41');
|
||||||
} else if (themeColor.includes('light')) {
|
} else if (themeColor.includes('light')) {
|
||||||
{{ $.Scratch.Set "themeTitleColor" "#555" }}
|
metaMsapplicationTileColor.setAttribute('content', '#555');
|
||||||
{{ $.Scratch.Set "themeNavbarColor" "#eee" }}
|
metaThemeColor.setAttribute('content', '#eee');
|
||||||
|
metaMsapplicationNavbuttonColor.setAttribute('content', '#eee');
|
||||||
|
metaAppleMobileWebAappStatusBarStyle.setAttribute('content', '#eee');
|
||||||
} else if (themeColor.includes('hacker')) {
|
} else if (themeColor.includes('hacker')) {
|
||||||
{{ $.Scratch.Set "themeTitleColor" "#e3cd26" }}
|
metaMsapplicationTileColor.setAttribute('content', '#e3cd26');
|
||||||
{{ $.Scratch.Set "themeNavbarColor" "#252526" }}
|
metaThemeColor.setAttribute('content', '#252526');
|
||||||
|
metaMsapplicationNavbuttonColor.setAttribute('content', '#252526');
|
||||||
|
metaAppleMobileWebAappStatusBarStyle.setAttribute('content', '#252526');
|
||||||
} else if (themeColor.includes('solarized')) {
|
} else if (themeColor.includes('solarized')) {
|
||||||
{{ $.Scratch.Set "themeTitleColor" "#586e75" }}
|
metaMsapplicationTileColor.setAttribute('content', '#d3af86');
|
||||||
{{ $.Scratch.Set "themeNavbarColor" "#eee8d5" }}
|
metaThemeColor.setAttribute('content', '#51412c');
|
||||||
|
metaMsapplicationNavbuttonColor.setAttribute('content', '#51412c');
|
||||||
|
metaAppleMobileWebAappStatusBarStyle.setAttribute('content', '#51412c');
|
||||||
} else if (themeColor.includes('kimbie')) {
|
} else if (themeColor.includes('kimbie')) {
|
||||||
{{ $.Scratch.Set "themeTitleColor" "#d3af86" }}
|
metaMsapplicationTileColor.setAttribute('content', '#586e75');
|
||||||
{{ $.Scratch.Set "themeNavbarColor" "#51412c" }}
|
metaThemeColor.setAttribute('content', '#eee8d5');
|
||||||
|
metaMsapplicationNavbuttonColor.setAttribute('content', '#eee8d5');
|
||||||
|
metaAppleMobileWebAappStatusBarStyle.setAttribute('content', '#eee8d5');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,6 +481,7 @@
|
||||||
elem.classList.remove('is-active');
|
elem.classList.remove('is-active');
|
||||||
}
|
}
|
||||||
}) : null;
|
}) : null;
|
||||||
|
|
||||||
setMetaColor(localTheme);
|
setMetaColor(localTheme);
|
||||||
} else {
|
} else {
|
||||||
setMetaColor(rootEleme.className);
|
setMetaColor(rootEleme.className);
|
||||||
|
@ -476,6 +492,7 @@
|
||||||
v.addEventListener('click', function (e) {
|
v.addEventListener('click', function (e) {
|
||||||
var selectedThemeVariant = e.target.text.trim();
|
var selectedThemeVariant = e.target.text.trim();
|
||||||
localStorage.setItem('theme', selectedThemeVariant);
|
localStorage.setItem('theme', selectedThemeVariant);
|
||||||
|
setMetaColor(selectedThemeVariant);
|
||||||
|
|
||||||
rootEleme.removeAttribute('class');
|
rootEleme.removeAttribute('class');
|
||||||
rootEleme.classList.add('theme__' + selectedThemeVariant);
|
rootEleme.classList.add('theme__' + selectedThemeVariant);
|
||||||
|
|
Loading…
Reference in New Issue