🏗️ Setup and use template.FuncMap in main
This commit is contained in:
parent
df55414167
commit
c680cca04b
19
main.go
19
main.go
|
@ -34,6 +34,7 @@ import (
|
|||
siteucase "source.toby3d.me/toby3d/home/internal/site/usecase"
|
||||
staticfsrepo "source.toby3d.me/toby3d/home/internal/static/repository/fs"
|
||||
staticucase "source.toby3d.me/toby3d/home/internal/static/usecase"
|
||||
"source.toby3d.me/toby3d/home/internal/templateutil"
|
||||
themefsrepo "source.toby3d.me/toby3d/home/internal/theme/repository/fs"
|
||||
themeucase "source.toby3d.me/toby3d/home/internal/theme/usecase"
|
||||
)
|
||||
|
@ -88,22 +89,24 @@ func main() {
|
|||
ctx := context.Background()
|
||||
|
||||
themeDir := os.DirFS(config.ThemeDir)
|
||||
|
||||
themes, err := themefsrepo.NewFileSystemThemeRepository(themeDir)
|
||||
partialsDir, err := fs.Sub(themeDir, "partials")
|
||||
if err != nil {
|
||||
logger.Fatalln(err)
|
||||
logger.Fatalln("cannot subtitute theme directory to partials subdirectory:", err)
|
||||
}
|
||||
|
||||
contentDir := os.DirFS(config.ContentDir)
|
||||
|
||||
statics := staticfsrepo.NewFileServerStaticRepository(contentDir)
|
||||
staticer := staticucase.NewStaticUseCase(statics)
|
||||
|
||||
themer := themeucase.NewThemeUseCase(themes)
|
||||
|
||||
sites := sitefsrepo.NewFileSystemSiteRepository(contentDir)
|
||||
siter := siteucase.NewSiteUseCase(sites, statics)
|
||||
|
||||
funcMap, err := templateutil.New(partialsDir, siter)
|
||||
if err != nil {
|
||||
logger.Fatalln("cannot setup template.FuncMap for templates: %w", err)
|
||||
}
|
||||
|
||||
staticer := staticucase.NewStaticUseCase(statics)
|
||||
themes := themefsrepo.NewFileSystemThemeRepository(themeDir, funcMap)
|
||||
themer := themeucase.NewThemeUseCase(themes)
|
||||
pages := pagefsrepo.NewFileSystemPageRepository(contentDir)
|
||||
pager := pageucase.NewPageUseCase(pages, statics)
|
||||
|
||||
|
|
Loading…
Reference in New Issue