diff --git a/templates/components/thread-card-text.html b/templates/components/thread-card-text.html new file mode 100644 index 0000000..fe36304 --- /dev/null +++ b/templates/components/thread-card-text.html @@ -0,0 +1,8 @@ +{{ define "thread-card-text" }} + {{ $length := len . }} + {{ if gt $length 300 }} +

{{ slice . 0 300 }} ...

+ {{ else }} +

{{ . }}

+ {{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/components/thread-card-title.html b/templates/components/thread-card-title.html new file mode 100644 index 0000000..2d1f297 --- /dev/null +++ b/templates/components/thread-card-title.html @@ -0,0 +1,5 @@ +{{ define "thread-card-title" }} + {{ if ne . "" }} +
{{ . }}
+ {{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/components/thread-card.html b/templates/components/thread-card.html index 1a86f1c..28349c0 100644 --- a/templates/components/thread-card.html +++ b/templates/components/thread-card.html @@ -8,17 +8,8 @@ {{ end }}
- {{ if ne .Title "" }} -
{{.Title}}
- {{ end }} - - {{ $textLength := len .Text }} - {{ if gt $textLength 300 }} -

{{ slice .Text 0 300 }} ...

- {{ else }} -

{{.Text}}

- {{ end }} - + {{ template "thread-card-title" .Title }} + {{ template "thread-card-text" .Text }} Open