diff options
author | Vikas Kushwaha <dev@vikas.rocks> | 2025-02-11 16:31:08 +0530 |
---|---|---|
committer | Vikas Kushwaha <dev@vikas.rocks> | 2025-02-11 16:31:08 +0530 |
commit | 57eb8f6712361a3bf75983ce153fac4846dc0273 (patch) | |
tree | 269a168d59c917c4e313c819e2b4c3ff8175f912 /cmd/web/templates/home/partials |
Initial commit
Diffstat (limited to 'cmd/web/templates/home/partials')
5 files changed, 113 insertions, 0 deletions
diff --git a/cmd/web/templates/home/partials/article-favorite-button.tmpl b/cmd/web/templates/home/partials/article-favorite-button.tmpl new file mode 100644 index 0000000..c26226a --- /dev/null +++ b/cmd/web/templates/home/partials/article-favorite-button.tmpl @@ -0,0 +1,6 @@ +<button class="btn btn-outline-primary btn-sm pull-xs-right {{ if .IsFavorited }} active {{ end }}" + hx-post="/htmx/home/articles/{{ .Slug }}/favorite" + hx-swap="outerHTML" +> + <i class="ion-heart"></i> {{ .GetFavoriteCount }} +</button>
\ No newline at end of file diff --git a/cmd/web/templates/home/partials/feed-navigation.tmpl b/cmd/web/templates/home/partials/feed-navigation.tmpl new file mode 100644 index 0000000..0a2356a --- /dev/null +++ b/cmd/web/templates/home/partials/feed-navigation.tmpl @@ -0,0 +1,17 @@ +<ul id="feed-navigation" class="nav nav-pills outline-active" hx-swap-oob="true"> + {{ range $item := .FeedNavbarItems }} + <li class="nav-item"> + <a class="nav-link {{ if $item.IsActive }} active {{ end }}" + {{ if not $item.IsActive }} + href="{{ $item.HXPushURL }}" + hx-get="{{ $item.HXGetURL }}" + hx-trigger="click" + hx-target="#feed-post-preview" + hx-push-url="{{ $item.HXPushURL }}" + {{ end }} + > + {{ $item.Title }} + </a> + </li> + {{ end }} +</ul>
\ No newline at end of file diff --git a/cmd/web/templates/home/partials/pagination.tmpl b/cmd/web/templates/home/partials/pagination.tmpl new file mode 100644 index 0000000..2ca4042 --- /dev/null +++ b/cmd/web/templates/home/partials/pagination.tmpl @@ -0,0 +1,18 @@ +<nav id="feed-pagination" hx-swap-oob="true"> + {{ if .HasPagination }} + {{ $CurrentPagination := .CurrentPagination }} + {{ $PathPagination := .PathPagination }} + {{ $PushPathPagination := .PushPathPagination }} + <ul class="pagination"> + {{ range $index := Iterate 1 .TotalPagination }} + <li class="page-item {{ if eq $CurrentPagination $index }} active {{ end }}"> + <a class="page-link" + href="/{{ $PathPagination }}?page={{ $index }}" + hx-push-url="/{{ $PushPathPagination }}?page={{ $index }}" + hx-get="/htmx/home/{{ $PathPagination }}?page={{ $index }}" + >{{ $index }}</a> + </li> + {{ end }} + </ul> + {{ end }} +</nav> diff --git a/cmd/web/templates/home/partials/post-preview.tmpl b/cmd/web/templates/home/partials/post-preview.tmpl new file mode 100644 index 0000000..7ef2111 --- /dev/null +++ b/cmd/web/templates/home/partials/post-preview.tmpl @@ -0,0 +1,60 @@ +<div id="feed-post-preview" hx-swap-oob="true"> + {{ if .HasArticles }} + {{ range $article := .Articles }} + + <div class="post-preview"> + <div class="post-meta"> + <a href="/users/{{ $article.User.Username }}" + hx-push-url="/users/{{ $article.User.Username }}" + hx-get="/htmx/users/{{ $article.User.Username }}" + hx-target="#app-body" + > + <img src="{{ $article.User.Image }}" /> + </a> + + <div class="info"> + <a href="/users/{{ $article.User.Username }}" + hx-push-url="/users/{{ $article.User.Username }}" + hx-get="/htmx/users/{{ $article.User.Username }}" + hx-target="#app-body" + class="author" + > + {{ $article.User.Name }} + </a> + <span class="date">{{ $article.GetFormattedCreatedAt }}</span> + </div> + + {{ template "home/partials/article-favorite-button" $article }} + + </div> + <a href="/articles/{{ $article.Slug }}" + hx-push-url="/articles/{{ $article.Slug }}" + hx-get="/htmx/articles/{{ $article.Slug }}" + hx-target="#app-body" + class="preview-link" + > + <h1>{{ $article.Title }}</h1> + <p>{{ $article.Description }}</p> + + <div class="m-t-1"> + <span>Read more...</span> + + <ul class="tag-list"> + {{ range $tag := $article.Tags }} + <li class="tag-default tag-pill tag-outline">{{ $tag.Name }}</li> + {{ end }} + </ul> + </div> + </a> + </div> + {{ end }} + {{ end }} + + {{ if not .HasArticles }} + <div class="post-preview"> + <div class="alert alert-warning" role="alert"> + No articles are here... yet. + </div> + </div> + {{ end }} +</div>
\ No newline at end of file diff --git a/cmd/web/templates/home/partials/tag-item-list.tmpl b/cmd/web/templates/home/partials/tag-item-list.tmpl new file mode 100644 index 0000000..eac4e53 --- /dev/null +++ b/cmd/web/templates/home/partials/tag-item-list.tmpl @@ -0,0 +1,12 @@ +<div id="popular-tag-list" class="tag-list" hx-swap-oob="true"> + {{ if .HasTags }} + {{ range $tag := .Tags }} + <a class="label label-pill label-default" + href="/tag-feed/{{ $tag.Name }}" + hx-get="/htmx/home/tag-feed/{{ $tag.Name }}" + hx-target="#feed-post-preview" + hx-push-url="/tag-feed/{{ $tag.Name }}" + >{{ $tag.Name }}</a> + {{ end }} + {{ end }} +</div>
\ No newline at end of file |