Add separate about and contact pages
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package about
|
||||
|
||||
import (
|
||||
. "ersteller-lib"
|
||||
|
||||
. "maragu.dev/gomponents"
|
||||
. "maragu.dev/gomponents/html"
|
||||
)
|
||||
|
||||
const AboutPath = "/about"
|
||||
const AboutPathDe = "/de/ueber-uns"
|
||||
|
||||
var aboutTexts *AboutTexts
|
||||
|
||||
type AboutTexts struct {
|
||||
PageTitle I18nText
|
||||
PageDescription I18nText
|
||||
HeroTitle I18nText
|
||||
HeroDescription I18nText
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
createPage CreateHtmxPageFunc
|
||||
ViewRoute HtmxRoute
|
||||
}
|
||||
|
||||
func NewPage(createPage CreateHtmxPageFunc, server HtmxServer, path *ActivePath) *Page {
|
||||
if aboutTexts == nil {
|
||||
createAboutTexts()
|
||||
}
|
||||
page := &Page{
|
||||
createPage: createPage,
|
||||
}
|
||||
page.ViewRoute = NewHtmxGetRoute(page.View, LanguagePaths{
|
||||
En: AboutPath,
|
||||
De: AboutPathDe,
|
||||
}).SetActivePath(path)
|
||||
page.ViewRoute.Add(server)
|
||||
return page
|
||||
}
|
||||
|
||||
func createAboutTexts() {
|
||||
aboutTexts = &AboutTexts{
|
||||
PageTitle: NewI18nText(map[Language]string{
|
||||
En: "About",
|
||||
De: "Über uns",
|
||||
}),
|
||||
PageDescription: NewI18nText(map[Language]string{
|
||||
En: "Learn more about us",
|
||||
De: "Erfahren Sie mehr über uns",
|
||||
}),
|
||||
HeroTitle: NewI18nText(map[Language]string{
|
||||
En: "About Us",
|
||||
De: "Über uns",
|
||||
}),
|
||||
HeroDescription: NewI18nText(map[Language]string{
|
||||
En: "This is a placeholder about page. Customize this content to tell your story.",
|
||||
De: "Dies ist eine Platzhalter-Über-uns-Seite. Passen Sie diesen Inhalt an, um Ihre Geschichte zu erzählen.",
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Page) getMetaData() PageWebsiteMetaData {
|
||||
return PageWebsiteMetaData{
|
||||
Title: aboutTexts.PageTitle,
|
||||
Lang: En,
|
||||
Description: aboutTexts.PageDescription,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Page) View(c HtmxContext) {
|
||||
content := AboutContent(c.GetLanguage())
|
||||
p.createPage(c, p.getMetaData(), content)
|
||||
}
|
||||
|
||||
func AboutContent(language Language) Group {
|
||||
return []Node{
|
||||
Div(Class("hero-section"),
|
||||
H1(Class("hero-title"), Text(aboutTexts.HeroTitle.FromLang(language))),
|
||||
P(Class("hero-description"), Text(aboutTexts.HeroDescription.FromLang(language))),
|
||||
),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user