md parser
This commit is contained in:
parent
0554bdb916
commit
9a3ecced33
|
@ -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")
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue