Add Technical Kiwi website with Go, templ, and HTMX.
Single-page site with gallery by album and event, contact form over SMTP, Docker dev/prod setup, and on-server image derivatives. Gallery photos stay local (app/images/ is gitignored). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
34
app/internal/gallery/hero.go
Normal file
34
app/internal/gallery/hero.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package gallery
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const defaultHeroRel = "connectionmachine/20220723_231556.jpg"
|
||||
|
||||
// HeroRelPath returns the configured hero image path relative to images/.
|
||||
func HeroRelPath() string {
|
||||
if p := strings.TrimSpace(os.Getenv("HERO_IMAGE")); p != "" {
|
||||
return filepathToSlash(p)
|
||||
}
|
||||
return defaultHeroRel
|
||||
}
|
||||
|
||||
// SelectHero picks the homepage hero from the gallery list.
|
||||
func SelectHero(images []Image) (Image, bool) {
|
||||
want := HeroRelPath()
|
||||
for _, img := range images {
|
||||
if img.RelPath == want {
|
||||
return img, true
|
||||
}
|
||||
}
|
||||
if len(images) > 0 {
|
||||
return images[0], true
|
||||
}
|
||||
return Image{}, false
|
||||
}
|
||||
|
||||
func filepathToSlash(p string) string {
|
||||
return strings.ReplaceAll(p, "\\", "/")
|
||||
}
|
||||
Reference in New Issue
Block a user