🗃️ Created simple theme FileSystem repository implementation

This commit is contained in:
Maxim Lebedev 2023-11-08 08:51:55 +06:00
parent c61ab4d929
commit 0e73130b78
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package fs
import (
"context"
"fmt"
"html/template"
"io/fs"
"source.toby3d.me/toby3d/home/internal/theme"
)
type fileSystemThemeRepository struct {
dir fs.FS
}
func NewFileSystemThemeRepository(dir fs.FS) theme.Repository {
return &fileSystemThemeRepository{
dir: dir,
}
}
func (repo *fileSystemThemeRepository) Get(ctx context.Context) (*template.Template, error) {
tpl, err := template.New("").ParseFS(repo.dir, "baseof.html", "single.html")
if err != nil {
return nil, fmt.Errorf("cannot find baseof.html: %w", err)
}
return tpl, nil
}