mirror of
https://github.com/imfing/hextra.git
synced 2025-08-24 06:56:45 -04:00
feat(banner): add top banner (#777)
* feat: add top banner * chore: use inside the example site * chore: generate * fix: banner with the burger navbar * fix: compute the banner height to allow mutliple lines * chore: better p style
This commit is contained in:

committed by
GitHub

parent
990d24906b
commit
f297d24189
18
layouts/_partials/banner.html
Normal file
18
layouts/_partials/banner.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{{- if site.Params.banner }}
|
||||
<div class="hextra-banner hx:max-md:sticky hx:top-0 hx:z-20 hx:px-6 hx:text-center hx:text-slate-50 hx:dark:text-white hx:bg-neutral-900 hx:dark:bg-neutral-800 hx:print:[display:none]">
|
||||
<div class="hx:relative hx:flex hx:items-center hx:justify-center hx:font-medium hx:text-sm hx:py-2.5">
|
||||
{{- with partial "custom/banner.html" . -}}
|
||||
{{- . -}}
|
||||
{{- else -}}
|
||||
<div style="white-space: pre-wrap" class="hx:px-8">
|
||||
{{- site.Params.banner.message | default "🎉 Welcome! This is a banner message." | .RenderString -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
<button
|
||||
class="hextra-banner-close-button hx:cursor-pointer hx:absolute hx:right-0 hx:text-white hx:font-bold hx:leading-none hx:hover:opacity-75 hx:transition hx:w-10 hx:h-10 hx:-mr-2 hx:md:mr-0 hx:flex hx:items-center hx:justify-center"
|
||||
>
|
||||
{{- partial "utils/icon.html" (dict "name" "x" "attributes" "height=16") -}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
0
layouts/_partials/custom/banner.html
Normal file
0
layouts/_partials/custom/banner.html
Normal file
@@ -77,6 +77,15 @@
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// The section must not be in the banner.js file because it can create a quick flash.
|
||||
|
||||
if (localStorage.getItem('{{ site.Params.banner.key | default `banner-closed` }}')) {
|
||||
document.documentElement.style.setProperty("--hextra-banner-height", "0px");
|
||||
document.documentElement.classList.add("hextra-banner-hidden");
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Math engine -->
|
||||
{{ $noop := .WordCount -}}
|
||||
{{- $engine := site.Params.math.engine | default "katex" -}}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
{{- $jsTheme := resources.Get "js/theme.js" | resources.ExecuteAsTemplate "theme.js" . -}}
|
||||
{{- $jsBanner := resources.Get "js/banner.js" | resources.ExecuteAsTemplate "banner.js" . -}}
|
||||
{{- $jsMenu := resources.Get "js/menu.js" -}}
|
||||
{{- $jsTabs := resources.Get "js/tabs.js" -}}
|
||||
{{- $jsLang := resources.Get "js/lang.js" -}}
|
||||
@@ -10,7 +11,7 @@
|
||||
{{- $jsTocScroll := resources.Get "js/toc-scroll.js" -}}
|
||||
{{- $jsFavicon := resources.Get "js/favicon.js" | resources.ExecuteAsTemplate "favicon.js" . -}}
|
||||
|
||||
{{- $scripts := slice $jsTheme $jsMenu $jsCodeCopy $jsTabs $jsLang $jsNavMenu $jsFileTree $jsSidebar $jsBackToTop $jsTocScroll $jsFavicon | resources.Concat "js/main.js" -}}
|
||||
{{- $scripts := slice $jsTheme $jsBanner $jsMenu $jsCodeCopy $jsTabs $jsLang $jsNavMenu $jsFileTree $jsSidebar $jsBackToTop $jsTocScroll $jsFavicon | resources.Concat "js/main.js" -}}
|
||||
{{- if hugo.IsProduction -}}
|
||||
{{- $scripts = $scripts | minify | fingerprint -}}
|
||||
{{- end -}}
|
||||
|
Reference in New Issue
Block a user