mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 14:22:33 +03:00
feat: separate thread card title and text components
This commit is contained in:
parent
2d065c1346
commit
6280a5fc9f
8
templates/components/thread-card-text.html
Normal file
8
templates/components/thread-card-text.html
Normal 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 }}
|
5
templates/components/thread-card-title.html
Normal file
5
templates/components/thread-card-title.html
Normal file
@ -0,0 +1,5 @@
|
||||
{{ define "thread-card-title" }}
|
||||
{{ if ne . "" }}
|
||||
<h5 class="card-title">{{ . }}</h5>
|
||||
{{ end }}
|
||||
{{ end }}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user