refactor(images): Move sponsor images to folder and load them dynamicly
This commit is contained in:
@@ -16,6 +16,22 @@ func GetTemplate(locale, templateName string) (string, error) {
|
||||
return string(content), nil
|
||||
}
|
||||
|
||||
func ListFilesInStaticSubFolder(folderName string) ([]string, error) {
|
||||
files, err := os.ReadDir(fmt.Sprintf("static/%s", folderName))
|
||||
if err != nil {
|
||||
log.Printf("error reading files from folder %s: %v", folderName, err)
|
||||
return nil, err
|
||||
}
|
||||
var images []string
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
continue
|
||||
}
|
||||
images = append(images, file.Name())
|
||||
}
|
||||
return images, nil
|
||||
}
|
||||
|
||||
func GetImage(imageName string) string {
|
||||
content, err := os.ReadFile("static/images/" + imageName + ".base64")
|
||||
if content == nil || err != nil {
|
||||
|
||||
Reference in New Issue
Block a user