-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b6202d
commit dce222e
Showing
6 changed files
with
78 additions
and
103 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
@import "_mixin/index"; | ||
|
||
@import "_core/base"; | ||
@import "_core/layout"; | ||
|
||
@import "_page/index"; | ||
|
||
|
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,20 @@ | ||
<div class="print:!tw-hidden tw-flex tw-flex-col tw-fixed tw-right-4 tw-bottom-4 tw-gap-2"> | ||
{{- /* top button */ -}} | ||
<a href="#back-to-top" id="back-to-top-button" class="tw-transition-opacity tw-opacity-0 tw-block tw-bg-bgColor-secondary tw-rounded-full" style="padding: 0.6rem; line-height: 1.3rem; font-size: 1rem;" title="{{ T `backToTop` }}"> | ||
{{ partial "plugin/fontawesome.html" (dict "Style" "solid" "Icon" "arrow-up") }} | ||
</a> | ||
|
||
{{/* toc dialog button */}} | ||
{{- if .Page.Scratch.Get "enableTocDialog" -}} | ||
<button id="toc-drawer-button" class="tw-block tw-bg-bgColor-secondary tw-rounded-full md:tw-hidden" style="padding: 0.6rem; line-height: 1.3rem; font-size: 1rem;"> | ||
{{ partial "plugin/fontawesome.html" (dict "Style" "solid" "Icon" "bars") }} | ||
</button> | ||
{{- end -}} | ||
|
||
{{- /* comment button */ -}} | ||
{{- if .Page.Scratch.Get "enableComment" -}} | ||
<a href="#comments" id="view-comments" class="tw-block tw-bg-bgColor-secondary tw-rounded-full" style="padding: 0.6rem; line-height: 1.3rem; font-size: 1rem;" title="{{ T `viewComments` }}"> | ||
{{ partial "plugin/fontawesome.html" (dict "Style" "solid" "Icon" "comment") }} | ||
</a> | ||
{{- end -}} | ||
</div> |
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,12 @@ | ||
{{/* Speculation Rules */}} | ||
{{/* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/speculationrules */}} | ||
<script type="speculationrules"> | ||
{ | ||
"prerender": [ | ||
{ | ||
"where": { "href_matches": "/*" }, | ||
"eagerness": "moderate" | ||
} | ||
] | ||
} | ||
</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,37 @@ | ||
{{- /* Check theme isDark before body rendering */ -}} | ||
{{- $theme := .Site.Params.defaulttheme -}} | ||
<script type="text/javascript"> | ||
function setTheme(theme) { | ||
document.body.setAttribute('theme', theme); | ||
document.documentElement.className = theme; | ||
document.documentElement.style.setProperty('color-scheme', theme === 'light' ? 'light' : 'dark'); | ||
if (theme === 'light') { | ||
document.documentElement.classList.remove('tw-dark') | ||
} else { | ||
document.documentElement.classList.add('tw-dark') | ||
} | ||
window.theme = theme; | ||
window.isDark = window.theme !== 'light' | ||
} | ||
function saveTheme(theme) {window.localStorage && localStorage.setItem('theme', theme);} | ||
function getMeta(metaName) {const metas = document.getElementsByTagName('meta'); for (let i = 0; i < metas.length; i++) if (metas[i].getAttribute('name') === metaName) return metas[i]; return '';} | ||
if (window.localStorage && localStorage.getItem('theme')) { | ||
let theme = localStorage.getItem('theme'); | ||
if (theme === 'light' || theme === 'dark') { | ||
setTheme(theme); | ||
} else { | ||
if ((window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)) { | ||
setTheme('dark'); | ||
} else { | ||
setTheme('light'); | ||
} | ||
} | ||
} else { | ||
if ('{{ $theme }}' === 'light' || '{{ $theme }}' === 'dark') | ||
setTheme('{{ $theme }}'), saveTheme('{{ $theme }}'); | ||
else saveTheme('auto'), window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? setTheme('dark') : setTheme('light'); | ||
} | ||
let metaColors = {'light': '#f8f8f8','dark': '#161b22'} | ||
getMeta('theme-color').content = metaColors[document.body.getAttribute('theme')]; | ||
window.switchThemeEventSet = new Set() | ||
</script> |