landing page templ & slick library

This commit is contained in:
Sas Andy
2024-04-29 10:10:24 +07:00
parent 99d7fd5159
commit d8e8f91fbd
41 changed files with 5957 additions and 13 deletions

View File

@@ -0,0 +1,48 @@
package handlers
import (
"fmt"
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/services"
landingpage "github.com/emarifer/go-templ-project-structure/views/LandingPage"
"github.com/labstack/echo/v4"
)
type LandingPageService interface {
GetClientService() ([]services.ClientService, error)
GetClientAdvantage() ([]services.AdvantageClient, error)
}
func NewLandingPageHandler(us LandingPageService) *LandingPageHandler {
return &LandingPageHandler{
LandingPageService: us,
}
}
type LandingPageHandler struct {
LandingPageService LandingPageService
}
func (uh *LandingPageHandler) ShowLandingPage(c echo.Context) error {
udata, err := uh.LandingPageService.GetClientService()
if err != nil {
// fmt.Println(err)
return err
}
adData, err := uh.LandingPageService.GetClientAdvantage()
if err != nil {
// fmt.Println(err)
return err
}
fmt.Printf("%+v\n", udata)
helo := landingpage.ShowLandingPage("Hello World", landingpage.MainLandingPage(udata, adData), landingpage.CssLandingPage(), landingpage.JsLandingPage())
return uh.View(c, helo)
}
func (uh *LandingPageHandler) View(c echo.Context, cmp templ.Component) error {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
return cmp.Render(c.Request().Context(), c.Response().Writer)
}

View File

@@ -15,6 +15,10 @@ func SetupRoutesXsample(app *echo.Echo, h *XsampleHandler) {
xSample := app.Group("/xsample")
xSample.GET("/xsample01", h.Hello)
}
func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler) {
Lp := app.Group("/landing_page")
Lp.GET("/", h.ShowLandingPage)
}
func SetupRoutesProject(app *echo.Echo) {
}