Organized home template markup.

This commit is contained in:
mikestefanello 2021-12-24 18:54:25 -05:00
parent b29de840f9
commit b4c4fae66b

View file

@ -1,5 +1,16 @@
{{define "content"}} {{define "content"}}
{{- if not (eq .HTMX.Request.Target "posts")}} {{- if not (eq .HTMX.Request.Target "posts")}}
{{template "top-content" .}}
{{- end}}
{{template "posts" .}}
{{- if not (eq .HTMX.Request.Target "posts")}}
{{template "file-msg" .}}
{{- end}}
{{end}}
{{define "top-content"}}
Hello homepage Hello homepage
<p><img src="{{file "gopher.png"}}" alt="Gopher"/></p> <p><img src="{{file "gopher.png"}}" alt="Gopher"/></p>
@ -9,9 +20,6 @@
Below is an example of both paging and AJAX fetching using HTMX Below is an example of both paging and AJAX fetching using HTMX
</h2> </h2>
</section> </section>
{{- end}}
{{template "posts" .}}
{{end}} {{end}}
{{define "posts"}} {{define "posts"}}
@ -49,3 +57,17 @@
</div> </div>
</div> </div>
{{end}} {{end}}
{{define "file-msg"}}
<article class="message is-small is-info mt-4" x-data="{show: true}" x-show="show">
<div class="message-header">
<p>Serving files</p>
<button class="delete is-small" aria-label="delete" x-on:click="show = false"></button>
</div>
<div class="message-body">
In the example posts above, check how the file URL contains a cache-buster query parameter which changes only when the app is restarted.
Static files also contain cache-control headers which are configured via middleware.
You can also use AlpineJS to dismiss this message.
</div>
</article>
{{end}}