From 9a3ecced33f4275c4376b6bcc1f973a82babc798 Mon Sep 17 00:00:00 2001 From: lorenzhohermuth Date: Tue, 30 Apr 2024 22:25:41 +0200 Subject: [PATCH] md parser --- cmd/main.go | 8 +++++--- internal/handler/handler.go | 17 ++++------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 4dab085..ce5d219 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -3,16 +3,18 @@ package main import ( "github.com/labstack/echo/v4" "github.com/lorenzhohermuth/portfolio/internal/handler" + "github.com/lorenzhohermuth/portfolio/internal/mdparser" ) func main() { app := echo.New() index := 0 - h := handler.Homehandler{index} + projects := mdparser.GetProjects() + h := handler.Homehandler{index, projects} app.GET("/", h.HandleUserShow) - app.POST("/carousel/next", handler.HtmxCarouselHandler{&index, 1}.HandlerCarouselUpdate) - app.POST("/carousel/previous", handler.HtmxCarouselHandler{&index, -1}.HandlerCarouselUpdate) + app.POST("/carousel/next", handler.HtmxCarouselHandler{&index, 1, projects}.HandlerCarouselUpdate) + app.POST("/carousel/previous", handler.HtmxCarouselHandler{&index, -1, projects}.HandlerCarouselUpdate) app.Static("/static", "assets") app.Start(":3030") diff --git a/internal/handler/handler.go b/internal/handler/handler.go index 451ac74..a83f54d 100644 --- a/internal/handler/handler.go +++ b/internal/handler/handler.go @@ -10,15 +10,10 @@ import ( type Homehandler struct { Index int + Entrys []component.CarouselEntry } func(h Homehandler) HandleUserShow(ctx echo.Context) error { - entrys := []component.CarouselEntry{ - {"/static/test.jpg", "This is a Tree" , "I like Trees"}, - {"/static/flower.jpeg", "This is a Flower" , "I like Flowers"}, - {"/static/paris.jpg", "This is the Eiffel Tower" , "I not like Franc"}, - } - events := []component.Event{ {time.Now(), time.Now(), "Title 1"}, {time.Now(), time.Now(), "Title 2"}, @@ -27,20 +22,16 @@ func(h Homehandler) HandleUserShow(ctx echo.Context) error { {time.Now(), time.Now(), "Title 5"}, } - return render(ctx, page.ShowHome(entrys, h.Index, events)) + return render(ctx, page.ShowHome(h.Entrys, h.Index, events)) } type HtmxCarouselHandler struct { Index *int Direction int + Entrys []component.CarouselEntry } func(h HtmxCarouselHandler) HandlerCarouselUpdate(ctx echo.Context) error { - entrys := []component.CarouselEntry{ - {"/static/test.jpg", "This is a Tree" , "I like Trees"}, - {"/static/flower.jpeg", "This is a Flower" , "I like Flowers"}, - {"/static/paris.jpg", "This is the Eiffel Tower" , "I not like Franc"}, - } *h.Index += h.Direction - return render(ctx, component.Carousel(entrys, int(*h.Index))) + return render(ctx, component.Carousel(h.Entrys, int(*h.Index))) }