Add HTMX Client Side Routing Optimization
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
export function Header() {
|
||||
return (
|
||||
<div>
|
||||
<header>
|
||||
<header hx-boost="true">
|
||||
<span>Caleb Braaten</span>
|
||||
<nav>
|
||||
<a href="/">Home</a>
|
||||
<a href="/blog">Blog</a>
|
||||
<a href="/projects">Projects</a>
|
||||
<a hx-target="main" href="/">Home</a>
|
||||
<a hx-target="main" href="/blog">Blog</a>
|
||||
<a hx-target="main" href="/projects">Projects</a>
|
||||
</nav>
|
||||
</header>
|
||||
<hr />
|
||||
|
||||
@@ -15,7 +15,9 @@ export function Index(path: string) {
|
||||
</head>
|
||||
<body>
|
||||
<Header />
|
||||
{page(path)}
|
||||
<main>
|
||||
{selectPage(path)}
|
||||
</main>
|
||||
<h1>Hello</h1>
|
||||
<button hx-get="/content/post">Click Me</button>
|
||||
</body>
|
||||
@@ -23,7 +25,7 @@ export function Index(path: string) {
|
||||
)
|
||||
}
|
||||
|
||||
function page(path: string) {
|
||||
export function selectPage(path: string) {
|
||||
switch (path) {
|
||||
case '/':
|
||||
return <Home />
|
||||
|
||||
Reference in New Issue
Block a user