diff --git a/api/routes/show.go b/api/routes/show.go index fb9a8b2..f55c37b 100644 --- a/api/routes/show.go +++ b/api/routes/show.go @@ -1,6 +1,7 @@ package routes import ( + "fmt" "html/template" "time" @@ -23,7 +24,22 @@ func show(c *fiber.Ctx) error { post := e.Data.Post publishDate := time.UnixMilli(e.Data.Post.CreatedAt) - p := converters.ConvertParagraphs(post.Content.BodyModel.Paragraphs) + paragraphs := post.Content.BodyModel.Paragraphs + + p := converters.ConvertParagraphs(paragraphs) + + desc := "" + if len(paragraphs) >= 0 { + desc = paragraphs[1].Text + } + + imgUrl := "" + for _, p := range paragraphs { + if p.Type == "IMG" { + imgUrl = fmt.Sprintf("https://miro.medium.com/v2/resize:fit:1200/%s", p.Metadata.ID) + break + } + } return c.Render("show", fiber.Map { "Title": post.Title, @@ -31,6 +47,9 @@ func show(c *fiber.Ctx) error { "Author": post.Creator.Name, "PublishDate": publishDate.Format(time.DateOnly), "Paragraphs": template.HTML(p), + "Description": desc, + "Path": c.Path(), + "Image": imgUrl, }) } diff --git a/frontend/show.html b/frontend/show.html index 0acac0c..77df924 100644 --- a/frontend/show.html +++ b/frontend/show.html @@ -14,6 +14,43 @@ rel="stylesheet">