mirror of
https://github.com/SphericalKat/medium.rip.git
synced 2026-10-21 01:34:22 +00:00
feat: implement markup rendering
Signed-off-by: Sphericalkat <amolele@gmail.com>
This commit is contained in:
1 parent
3de9bfc58c
commit
7b6e7d7edb
8 files changed
+195
-52
No files matched your search
+4
-13
@@ -1,13 +1,12 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"html/template"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/medium.rip/pkg/client"
|
||||
"github.com/medium.rip/pkg/converters"
|
||||
)
|
||||
|
||||
func show(c *fiber.Ctx) error {
|
||||
@@ -23,23 +22,15 @@ func show(c *fiber.Ctx) error {
|
||||
|
||||
post := e.Data.Post
|
||||
publishDate := time.UnixMilli(e.Data.Post.CreatedAt)
|
||||
log.Println(publishDate)
|
||||
|
||||
var sb strings.Builder
|
||||
|
||||
for _, node := range post.Content.BodyModel.Paragraphs {
|
||||
switch node.Type {
|
||||
case "H3":
|
||||
sb.WriteString(fmt.Sprintf("<h3>%s</h3>", node.Text))
|
||||
}
|
||||
}
|
||||
p := converters.ConvertParagraphs(post.Content.BodyModel.Paragraphs)
|
||||
|
||||
return c.Render("show", fiber.Map {
|
||||
"Title": post.Title,
|
||||
"UserId": post.Creator.ID,
|
||||
"Author": post.Creator.Name,
|
||||
"PublishDate": publishDate.Format(time.DateOnly),
|
||||
"Nodes": post.Content.BodyModel.Paragraphs,
|
||||
"Paragraphs": template.HTML(p),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user