move templates to web dir
This commit is contained in:
@@ -17,7 +17,7 @@ func (ord articleDateOrder) Weight(a *model.Article) int {
|
||||
// List the latest articles using the base template.
|
||||
func Index(w http.ResponseWriter, req *http.Request) {
|
||||
// retrieve from repo
|
||||
fds, err := data.NewFileDatastore("./persistence/spiegel100.json")
|
||||
fds, err := data.NewFileDatastore("persistence/spiegel100.json")
|
||||
if err != nil { http.Error(w, "Failed to load datastore", http.StatusInternalServerError); return; }
|
||||
repo, err := data.NewDefaultRepository[*model.Article](fds, "article")
|
||||
if err != nil { http.Error(w, "Failed to create repository", http.StatusInternalServerError); return; }
|
||||
@@ -36,7 +36,7 @@ func Index(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
// render template
|
||||
t := template.Must(template.ParseFiles("templates/article.html", "templates/layout.html"))
|
||||
t := template.Must(template.ParseFiles("web/templates/article.html", "web/templates/layout.html"))
|
||||
err = t.ExecuteTemplate(w, "base", articleVMs)
|
||||
if err != nil { http.Error(w, "Failed to render template", http.StatusInternalServerError); return; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user