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>
35 lines
708 B
Go
35 lines
708 B
Go
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, "\\", "/")
|
|
}
|