feat: add algorithm to parse ranges with markup

Signed-off-by: Sphericalkat <amolele@gmail.com>
This commit is contained in:
sphericalkat committed 2023-05-27 22:57:56 +05:30
1 parent 848cd514d0
commit 4b8607b12a
16 files changed
+814 -13

No files matched your search

+25 -1
View File
@@ -1,6 +1,11 @@
package routes
import (
"fmt"
"log"
"strings"
"time"
"github.com/gofiber/fiber/v2"
"github.com/medium.rip/pkg/client"
)
@@ -16,7 +21,26 @@ func show(c *fiber.Ctx) error {
return err
}
return c.JSON(e)
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))
}
}
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,
})
}
func index(c *fiber.Ctx) error {