Adding the wiki route and better styling

This commit is contained in:
ngn
2024-01-06 23:20:58 +03:00
parent 6477240dd4
commit 7f61a0cd58
15 changed files with 299 additions and 161 deletions

53
routes/wiki.go Normal file
View File

@ -0,0 +1,53 @@
package routes
import (
"git.matterlinux.xyz/Matterlinux/website/lib"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/log"
)
func WikiMainRoute(c *fiber.Ctx) error {
con, err := lib.GetContent("wiki", "main")
if err != nil {
log.Error("GetContent -> ", err)
return lib.RenderError(c, 500)
}
return c.Render("post", fiber.Map{
"title": "Wiki",
"post": con,
})
}
func WikiRoute(c *fiber.Ctx) error{
docid := c.Params("id")
if len(docid) == 0 {
return lib.RenderError(c, 404)
}
contents, err := lib.ListContent("wiki")
if err != nil {
log.Errorf("ListContent -> %s", err.Error())
return lib.RenderError(c, 500)
}
for _, con := range contents {
if(con.ID != docid) {
continue
}
con, err = lib.GetContent(con.Dir, con.Name)
if err != nil {
log.Errorf("GetContent -> %s", err.Error())
return lib.RenderError(c, 500)
}
con.Title = "Wiki: "+con.Title
return c.Render("post", fiber.Map{
"title": "Wiki",
"post": con,
})
}
return lib.RenderError(c, 404)
}