From c73c6e9aeceeefc07a1f9e1959dcf9d29ea3d74a Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Sun, 30 Jan 2022 14:09:55 +0200 Subject: [PATCH] feat: separate thread card --- templates/components/thread-card.html | 26 ++++++++++++++++++++++++++ templates/pages/index.html | 27 +-------------------------- 2 files changed, 27 insertions(+), 26 deletions(-) create mode 100644 templates/components/thread-card.html diff --git a/templates/components/thread-card.html b/templates/components/thread-card.html new file mode 100644 index 0000000..c8d067a --- /dev/null +++ b/templates/components/thread-card.html @@ -0,0 +1,26 @@ +{{ define "thread-card" }} +
+
+ {{ $length := len .Files }} + {{ if gt $length 0 }} + {{ $FirstFile := index .Files 0 }} + Uploaded picture + {{ end }} + +
+ {{ if ne .Title "" }} +
{{.Title}}
+ {{ end }} + + {{ $textLength := len .Text }} + {{ if gt $textLength 300 }} +

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

+ {{ else }} +

{{.Text}}

+ {{ end }} + + Open +
+
+
+{{ end }} \ No newline at end of file diff --git a/templates/pages/index.html b/templates/pages/index.html index 6c0f383..d1689f7 100644 --- a/templates/pages/index.html +++ b/templates/pages/index.html @@ -15,32 +15,7 @@
{{ range $Post := .Threads }} -
-
- - {{ $length := len $Post.Files }} - {{ if gt $length 0 }} - {{ $FirstFile := index $Post.Files 0 }} - Uploaded picture - {{ end }} - -
- {{ if ne $Post.Title "" }} -
{{$Post.Title}}
- {{ end }} - - {{ $textLength := len $Post.Text }} - {{ if gt $textLength 300 }} -

{{ slice $Post.Text 0 300 }} ...

- {{ else }} -

{{$Post.Text}}

- {{ end }} - - Open -
-
-
+ {{ template "thread-card" $Post }} {{ end }}