2024-09-20 16:45:23 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2024-09-26 19:40:09 +00:00
|
|
|
"github.com/labstack/echo/v4"
|
2024-09-20 16:45:23 +00:00
|
|
|
"github.com/maddalax/htmgo/framework/h"
|
2024-09-23 01:59:44 +00:00
|
|
|
"github.com/maddalax/htmgo/framework/service"
|
2024-09-23 02:15:53 +00:00
|
|
|
"htmgo-site/__htmgo"
|
2024-09-20 16:45:23 +00:00
|
|
|
"htmgo-site/internal/markdown"
|
2024-09-20 18:25:14 +00:00
|
|
|
"io/fs"
|
2024-09-20 16:45:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
locator := service.NewLocator()
|
2024-09-25 15:44:43 +00:00
|
|
|
staticAssets := GetStaticAssets()
|
|
|
|
|
markdownAssets := GetMarkdownAssets()
|
2024-09-20 16:45:23 +00:00
|
|
|
|
|
|
|
|
service.Set(locator, service.Singleton, markdown.NewRenderer)
|
|
|
|
|
|
|
|
|
|
h.Start(h.AppOpts{
|
|
|
|
|
ServiceLocator: locator,
|
|
|
|
|
LiveReload: true,
|
2024-09-26 19:40:09 +00:00
|
|
|
Register: func(e *echo.Echo) {
|
2024-09-25 15:44:43 +00:00
|
|
|
sub, err := fs.Sub(staticAssets, "assets/dist")
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
2024-09-26 19:40:09 +00:00
|
|
|
e.StaticFS("/public", sub)
|
2024-09-20 18:25:14 +00:00
|
|
|
|
2024-09-26 19:40:09 +00:00
|
|
|
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
|
|
|
return func(c echo.Context) error {
|
|
|
|
|
c.Set("embeddedMarkdown", markdownAssets)
|
|
|
|
|
return next(c)
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-09-20 18:25:14 +00:00
|
|
|
|
2024-09-26 19:40:09 +00:00
|
|
|
__htmgo.Register(e)
|
2024-09-20 16:45:23 +00:00
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|