-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.go
44 lines (40 loc) · 1.27 KB
/
category.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package presenter
import (
"html/template"
"net/http"
"os"
"github.com/bmf-san/gobel-client-example/app/model"
)
// CategoryIndex is a data for index template.
type CategoryIndex struct {
Categories *model.Categories
Pagination *Pagination
}
// ExecuteCategoryIndex responses a index template.
func (p *Presenter) ExecuteCategoryIndex(w http.ResponseWriter, r *http.Request, c *CategoryIndex) error {
fm := template.FuncMap{
"year": p.year,
"isAd": p.IsAd,
}
u := os.Getenv("BASE_URL") + "/categories"
m := &model.Meta{
Title: "gobel-client-example.com - カテゴリ一覧",
Canonical: u,
Description: "カテゴリ一覧",
OGTitle: "カテゴリ一覧",
OGDescription: "カテゴリ一覧",
OGURL: u,
OGType: "article",
OGImage: "",
OGSiteName: "gobel-client-example",
OGLocale: "ja_JP",
TwitterCard: "summary",
TwitterSite: "@bmf_san",
NoIndex: false,
}
tpl := template.Must(template.New("base").Funcs(fm).ParseFS(p.templates, "templates/layout/base.tpl", "templates/partial/meta.tpl", "templates/category/index.tpl", "templates/partial/pagination.tpl"))
if err := tpl.ExecuteTemplate(w, "base", map[string]interface{}{"Meta": m, "Categories": c}); err != nil {
return err
}
return nil
}