Fix dataimg path bug

This commit is contained in:
Ben Visness 2023-06-01 21:18:48 -05:00
parent 1ea9fbefbc
commit 57782aba5f
1 changed files with 4 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import (
"io" "io"
"io/fs" "io/fs"
"net/http" "net/http"
"path/filepath"
"regexp" "regexp"
"strings" "strings"
"time" "time"
@ -111,15 +112,16 @@ func names(ts []*template.Template) []string {
//go:embed img/* //go:embed img/*
var Imgs embed.FS var Imgs embed.FS
func GetImg(filepath string) []byte { func GetImg(file string) []byte {
var imgs fs.FS var imgs fs.FS
if config.Config.DevConfig.LiveTemplates { if config.Config.DevConfig.LiveTemplates {
imgs = utils.DirFS("src/templates/img") imgs = utils.DirFS("src/templates/img")
} else { } else {
imgs = Imgs imgs = Imgs
file = filepath.Join("img/", file)
} }
img, err := imgs.Open(filepath) img, err := imgs.Open(file)
if err != nil { if err != nil {
panic(err) panic(err)
} }