saasitone/pkg/routes/about.go

71 lines
2.0 KiB
Go
Raw Normal View History

2021-12-14 08:13:53 -08:00
package routes
2021-12-03 03:11:01 -08:00
import (
"html/template"
2022-11-02 16:23:26 -07:00
"github.com/mikestefanello/pagoda/pkg/controller"
"github.com/mikestefanello/pagoda/templates"
2021-12-03 03:11:01 -08:00
"github.com/labstack/echo/v4"
)
type (
2022-02-10 05:56:07 -08:00
about struct {
controller.Controller
}
2022-02-10 05:56:07 -08:00
aboutData struct {
ShowCacheWarning bool
2022-02-10 05:56:07 -08:00
FrontendTabs []aboutTab
BackendTabs []aboutTab
}
2022-02-10 05:56:07 -08:00
aboutTab struct {
Title string
Body template.HTML
}
)
2021-12-03 03:11:01 -08:00
2022-02-10 05:56:07 -08:00
func (c *about) Get(ctx echo.Context) error {
page := controller.NewPage(ctx)
page.Layout = templates.LayoutMain
page.Name = templates.PageAbout
page.Title = "About"
// This page will be cached!
page.Cache.Enabled = true
page.Cache.Tags = []string{"page_about", "page:list"}
2021-12-03 03:11:01 -08:00
// A simple example of how the Data field can contain anything you want to send to the templates
2021-12-25 11:20:49 -08:00
// even though you wouldn't normally send markup like this
2022-02-10 05:56:07 -08:00
page.Data = aboutData{
ShowCacheWarning: true,
2022-02-10 05:56:07 -08:00
FrontendTabs: []aboutTab{
{
Title: "HTMX",
Body: template.HTML(`Completes HTML as a hypertext by providing attributes to AJAXify anything and much more. Visit <a href="https://htmx.org/">htmx.org</a> to learn more.`),
},
{
Title: "Alpine.js",
Body: template.HTML(`Drop-in, Vue-like functionality written directly in your markup. Visit <a href="https://alpinejs.dev/">alpinejs.dev</a> to learn more.`),
},
{
Title: "Bulma",
Body: template.HTML(`Ready-to-use frontend components that you can easily combine to build responsive web interfaces with no JavaScript requirements. Visit <a href="https://bulma.io/">bulma.io</a> to learn more.`),
},
},
2022-02-10 05:56:07 -08:00
BackendTabs: []aboutTab{
2021-12-25 11:20:49 -08:00
{
Title: "Echo",
Body: template.HTML(`High performance, extensible, minimalist Go web framework. Visit <a href="https://echo.labstack.com/">echo.labstack.com</a> to learn more.`),
},
{
Title: "Ent",
Body: template.HTML(`Simple, yet powerful ORM for modeling and querying data. Visit <a href="https://entgo.io/">entgo.io</a> to learn more.`),
},
},
}
return c.RenderPage(ctx, page)
2021-12-03 03:11:01 -08:00
}