mirror of
https://github.com/imfing/hextra.git
synced 2025-07-10 08:01:41 -04:00
Compare commits
4 Commits
7e8c0d17da
...
c656e42f3e
Author | SHA1 | Date | |
---|---|---|---|
c656e42f3e | |||
97ea67198b | |||
368c20e935 | |||
9e684fa313 |
@ -1,4 +1,9 @@
|
|||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
scrollToActiveItem();
|
||||||
|
enableCollapsibles();
|
||||||
|
});
|
||||||
|
|
||||||
|
function enableCollapsibles() {
|
||||||
const buttons = document.querySelectorAll(".hextra-sidebar-collapsible-button");
|
const buttons = document.querySelectorAll(".hextra-sidebar-collapsible-button");
|
||||||
buttons.forEach(function (button) {
|
buttons.forEach(function (button) {
|
||||||
button.addEventListener("click", function (e) {
|
button.addEventListener("click", function (e) {
|
||||||
@ -9,4 +14,23 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
function scrollToActiveItem() {
|
||||||
|
const sidebarScrollbar = document.querySelector("aside.sidebar-container > .hextra-scrollbar");
|
||||||
|
const activeItems = document.querySelectorAll(".sidebar-active-item");
|
||||||
|
const visibleActiveItem = Array.from(activeItems).find(function (activeItem) {
|
||||||
|
return activeItem.getBoundingClientRect().height > 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!visibleActiveItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const yOffset = visibleActiveItem.clientHeight;
|
||||||
|
const yDistance = visibleActiveItem.getBoundingClientRect().top - sidebarScrollbar.getBoundingClientRect().top;
|
||||||
|
sidebarScrollbar.scrollTo({
|
||||||
|
behavior: "instant",
|
||||||
|
top: yDistance - yOffset
|
||||||
|
});
|
||||||
|
}
|
||||||
|
10
layouts/shortcodes/hextra/hero-section.html
Normal file
10
layouts/shortcodes/hextra/hero-section.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{{- $style := .Get "style" -}}
|
||||||
|
{{- $header := int (strings.TrimPrefix "h" (.Get "header" | default "h2")) -}}
|
||||||
|
{{- $size := cond (ge $header 4) "xl" (cond (eq $header 3) "2xl" "4xl") -}}
|
||||||
|
|
||||||
|
<h{{ $header }}
|
||||||
|
class="not-prose hx-text-{{ $size }} hx-font-bold hx-leading-none hx-tracking-tighter md:hx-text-3xl hx-py-2 hx-bg-clip-text hx-text-transparent hx-bg-gradient-to-r hx-from-gray-900 hx-to-gray-600 dark:hx-from-gray-100 dark:hx-to-gray-400"
|
||||||
|
{{ with $style }}style="{{ . | safeCSS }}"{{ end }}
|
||||||
|
>
|
||||||
|
{{ .Inner | markdownify }}
|
||||||
|
</h{{ $header }}>
|
Reference in New Issue
Block a user