🗃️ Created simple theme FileSystem repository implementation
This commit is contained in:
parent
c61ab4d929
commit
0e73130b78
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue