113 lines
3.0 KiB
Go
113 lines
3.0 KiB
Go
package routes
|
|
|
|
import (
|
|
. "ersteller-lib"
|
|
"ersteller-lib/starter/index"
|
|
"ersteller-lib/starter/page"
|
|
"net/http"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
. "maragu.dev/gomponents"
|
|
. "maragu.dev/gomponents/html"
|
|
)
|
|
|
|
func CreateApi(db *pgxpool.Pool) http.Handler {
|
|
server := NewHtmxServer()
|
|
|
|
HtmxRouteDebugTrace = true
|
|
|
|
indexActivePath := NewActivePath(map[Language]string{
|
|
En: "Home",
|
|
De: "Startseite",
|
|
}, LanguagePaths{
|
|
En: index.IndexPath,
|
|
De: index.IndexPathDe,
|
|
})
|
|
|
|
aboutActivePath := NewActivePath(map[Language]string{
|
|
En: "About",
|
|
De: "Über uns",
|
|
}, LanguagePaths{
|
|
En: "/about",
|
|
De: "/de/ueber-uns",
|
|
})
|
|
|
|
contactActivePath := NewActivePath(map[Language]string{
|
|
En: "Contact",
|
|
De: "Kontakt",
|
|
}, LanguagePaths{
|
|
En: "/contact",
|
|
De: "/de/kontakt",
|
|
})
|
|
|
|
// Main navigation items
|
|
activePaths := []ActivePath{indexActivePath, aboutActivePath, contactActivePath}
|
|
|
|
// Footer navigation items (placeholder - can be customized)
|
|
footerPaths := []ActivePath{}
|
|
|
|
createPageFunc := createPage(activePaths, footerPaths)
|
|
indexPage := index.NewPage(createPageFunc, server, &indexActivePath)
|
|
server.HandleStaticAndDefaultPath(indexPage.ViewRoute, En)
|
|
|
|
// Add placeholder routes for About and Contact pages
|
|
// These can be implemented as needed
|
|
aboutRoute := NewHtmxGetRoute(func(c HtmxContext) {
|
|
content := []Node{
|
|
Div(Class("hero-section"),
|
|
H1(Class("hero-title"), Text("About Us")),
|
|
P(Class("hero-description"), Text("This is a placeholder about page. Customize this content to tell your story.")),
|
|
),
|
|
}
|
|
createPageFunc(c, PageWebsiteMetaData{
|
|
Title: NewI18nText(map[Language]string{
|
|
En: "About",
|
|
De: "Über uns",
|
|
}),
|
|
Description: NewI18nText(map[Language]string{
|
|
En: "Learn more about us",
|
|
De: "Erfahren Sie mehr über uns",
|
|
}),
|
|
}, content...)
|
|
}, LanguagePaths{
|
|
En: "/about",
|
|
De: "/de/ueber-uns",
|
|
}).SetActivePath(&aboutActivePath)
|
|
aboutRoute.Add(server)
|
|
|
|
contactRoute := NewHtmxGetRoute(func(c HtmxContext) {
|
|
content := []Node{
|
|
Div(Class("hero-section"),
|
|
H1(Class("hero-title"), Text("Contact Us")),
|
|
P(Class("hero-description"), Text("This is a placeholder contact page. Add your contact information and forms here.")),
|
|
),
|
|
}
|
|
createPageFunc(c, PageWebsiteMetaData{
|
|
Title: NewI18nText(map[Language]string{
|
|
En: "Contact",
|
|
De: "Kontakt",
|
|
}),
|
|
Description: NewI18nText(map[Language]string{
|
|
En: "Get in touch with us",
|
|
De: "Nehmen Sie Kontakt mit uns auf",
|
|
}),
|
|
}, content...)
|
|
}, LanguagePaths{
|
|
En: "/contact",
|
|
De: "/de/kontakt",
|
|
}).SetActivePath(&contactActivePath)
|
|
contactRoute.Add(server)
|
|
|
|
serverWithMiddleWare := UseMiddleware(server, LoggingMiddleware, MakeGzipHandler)
|
|
|
|
return serverWithMiddleWare
|
|
}
|
|
|
|
func createPage(activePaths []ActivePath, footerPaths []ActivePath) CreateHtmxPageFunc {
|
|
return func(req HtmxContext, metadata PageWebsiteMetaData, content ...Node) {
|
|
metadata.NavItems = activePaths
|
|
metadata.FooterNavItems = footerPaths
|
|
page.CreatePage(req, metadata, content...)
|
|
}
|
|
}
|