69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package routes
|
|
|
|
import (
|
|
. "ersteller-lib"
|
|
"ersteller-lib/starter/about"
|
|
"ersteller-lib/starter/contact"
|
|
"ersteller-lib/starter/index"
|
|
"ersteller-lib/starter/page"
|
|
"net/http"
|
|
|
|
. "maragu.dev/gomponents"
|
|
)
|
|
|
|
func CreateApi() 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.AboutPath,
|
|
De: about.AboutPathDe,
|
|
})
|
|
|
|
contactActivePath := NewActivePath(map[Language]string{
|
|
En: "Contact",
|
|
De: "Kontakt",
|
|
}, LanguagePaths{
|
|
En: contact.ContactPath,
|
|
De: contact.ContactPathDe,
|
|
})
|
|
|
|
// 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)
|
|
|
|
// Create About and Contact pages using the new packages
|
|
_ = about.NewPage(createPageFunc, server, &aboutActivePath)
|
|
_ = contact.NewPage(createPageFunc, server, &contactActivePath)
|
|
|
|
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...)
|
|
}
|
|
}
|