-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (33 loc) · 843 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"html/template"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html"
"github.com/kelseyhightower/envconfig"
"github.com/microcosm-cc/bluemonday"
"github.com/russross/blackfriday"
)
func main() {
var conf Config
err := envconfig.Process("penguinmeta", &conf)
if err != nil {
panic(err)
}
engine := html.New("./web/dist", ".html")
app := fiber.New(fiber.Config{
Views: engine,
GETOnly: true,
})
body := blackfriday.MarkdownBasic([]byte(conf.Index.Body))
body = bluemonday.UGCPolicy().SanitizeBytes(body)
app.Get("/", func(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{
"Title": conf.Index.Title,
"Body": template.HTML(string(body)),
})
})
app.All("*", func(c *fiber.Ctx) error {
return c.Redirect("https://exusiai.dev")
})
app.Listen(conf.Address)
}