hikan.ru/mvc/views/pages/posts/posts_ajax.gohtml

41 lines
1.2 KiB
Plaintext

{{ template "posts_ajax" . }}
{{ define "posts_ajax" }}
<main>
<div>
<p>
<code>posts sorted by create time</code>
</p>
</div>
{{ range $ind, $post := .posts }}
<div>
<p>
{{ $post.Preview }}
</p>
<p>
<a href="{{ $post.Link }}"
hx-get="{{ $post.Link }}?ajax=true"
hx-target="main"
hx-swap="outerHTML"
hx-push-url="{{ $post.Link }}">read more</a>
</p>
<p>
<code>create time: {{ $post.Timestamp }}</code>
</p>
</div>
{{ end }}
<div class="pagi">
<a href="/posts/{{ .prevPageNumber }}"
hx-get="/posts/{{ .prevPageNumber }}?ajax=true"
hx-target="main"
hx-swap="outerHTML"
hx-push-url="/posts/{{ .prevPageNumber }}"><-</a>
{{ .pageNumberInc }}/{{ .pagesCount }}
<a href="/posts/{{ .nextPageNumber }}"
hx-get="/posts/{{ .nextPageNumber }}?ajax=true"
hx-target="main"
hx-swap="outerHTML"
hx-push-url="/posts/{{ .nextPageNumber }}">-></a>
</div>
</main>
{{ end }}