feat: separate thread card title and text components

This commit is contained in:
Yanislav Igonin 2022-02-02 15:03:40 +02:00
parent 2d065c1346
commit 6280a5fc9f
3 changed files with 15 additions and 11 deletions

View File

@ -0,0 +1,8 @@
{{ define "thread-card-text" }}
{{ $length := len . }}
{{ if gt $length 300 }}
<p class="card-text line-break text-break">{{ slice . 0 300 }} ...</p>
{{ else }}
<p class="card-text line-break text-break">{{ . }}</p>
{{ end }}
{{ end }}

View File

@ -0,0 +1,5 @@
{{ define "thread-card-title" }}
{{ if ne . "" }}
<h5 class="card-title">{{ . }}</h5>
{{ end }}
{{ end }}

View File

@ -8,17 +8,8 @@
{{ end }}
<div class="card-body">
{{ if ne .Title "" }}
<h5 class="card-title">{{.Title}}</h5>
{{ end }}
{{ $textLength := len .Text }}
{{ if gt $textLength 300 }}
<p class="card-text line-break text-break">{{ slice .Text 0 300 }} ...</p>
{{ else }}
<p class="card-text line-break text-break">{{.Text}}</p>
{{ end }}
{{ template "thread-card-title" .Title }}
{{ template "thread-card-text" .Text }}
<a href="/{{.ID}}" class="btn btn-outline-primary">Open</a>
</div>
</div>