fix(htmx): implement persistent shell pattern by targeting #main-content
All checks were successful
Deploy Theme / deploy (push) Successful in 13s
All checks were successful
Deploy Theme / deploy (push) Successful in 13s
This commit is contained in:
24
default.hbs
24
default.hbs
@@ -10,6 +10,11 @@
|
||||
});
|
||||
document.documentElement.setAttribute('data-theme', this.theme);
|
||||
document.documentElement.classList.remove('hidden');
|
||||
|
||||
// Close mobile menu on navigation
|
||||
document.addEventListener('htmx:beforeRequest', () => {
|
||||
this.mobileMenuOpen = false;
|
||||
});
|
||||
}
|
||||
}"
|
||||
:data-theme="theme"
|
||||
@@ -28,24 +33,23 @@
|
||||
|
||||
{{ghost_head}}
|
||||
</head>
|
||||
<body class="{{body_class}} font-sans antialiased">
|
||||
|
||||
{{!-- The Mobile Menu is outside the HTMX swap container to keep state alive --}}
|
||||
<body
|
||||
class="{{body_class}} font-sans antialiased min-h-screen flex flex-col"
|
||||
hx-boost="true"
|
||||
hx-target="#main-content"
|
||||
hx-select="#main-content"
|
||||
hx-swap="innerHTML show:top"
|
||||
>
|
||||
{{!-- Mobile menu is outside the swap target and stays alive --}}
|
||||
{{> mobile-menu}}
|
||||
|
||||
{{!--
|
||||
We target only this container for HTMX page swaps.
|
||||
This keeps root Alpine state (like mobileMenuOpen) persistent.
|
||||
--}}
|
||||
<div id="viewport" class="min-h-screen flex flex-col" hx-boost="true" hx-target="#viewport" hx-select="#viewport">
|
||||
{{> header}}
|
||||
|
||||
<main class="flex-grow">
|
||||
<main id="main-content" class="flex-grow">
|
||||
{{{body}}}
|
||||
</main>
|
||||
|
||||
{{> footer}}
|
||||
</div>
|
||||
|
||||
{{ghost_foot}}
|
||||
<script src="{{asset "js/ghost-config.js"}}"></script>
|
||||
|
||||
Reference in New Issue
Block a user