diff --git a/config.go b/config.go
index 06d5b72..0cb680b 100644
--- a/config.go
+++ b/config.go
@@ -46,6 +46,8 @@ type configBlog struct {
Sections []*section `mapstructure:"sections"`
// Taxonomies
Taxonomies []*taxonomy `mapstructure:"taxonomies"`
+ // Menus
+ Menus []*menu `mapstructure:"menus"`
}
type section struct {
@@ -60,6 +62,16 @@ type taxonomy struct {
Description string `mapstructure:"description"`
}
+type menu struct {
+ Id string `mapstructure:"id"`
+ Items []*menuItem `mapstructure:"items"`
+}
+
+type menuItem struct {
+ Title string `mapstructure:"title"`
+ Link string `mapstructure:"link"`
+}
+
type configUser struct {
Nick string `mapstructure:"nick"`
Name string `mapstructure:"name"`
@@ -101,6 +113,7 @@ func initConfig() error {
viper.SetDefault("blog.pagination", 10)
viper.SetDefault("blog.sections", []*section{{Name: "posts", Title: "Posts", Description: "**Posts** on this blog"}})
viper.SetDefault("blog.taxonomies", []*taxonomy{{Name: "tags", Title: "Tags", Description: "**Tags** on this blog"}})
+ viper.SetDefault("blog.menus", []*menu{{Id: "main", Items: []*menuItem{{Title: "Home", Link: "/"}, {Title: "Post", Link: "Posts"}}}})
viper.SetDefault("user.nick", "admin")
viper.SetDefault("user.name", "Admin")
viper.SetDefault("user.password", "secret")
diff --git a/example-config.yaml b/example-config.yaml
index 226ecc7..1333610 100644
--- a/example-config.yaml
+++ b/example-config.yaml
@@ -23,6 +23,13 @@ blog:
- name: tags
title: Tags
description: "**Tags** on this blog"
+ menus:
+ - id: main
+ items:
+ - title: Home
+ link: /
+ - title: Posts
+ link: /posts
user:
nick: admin
name: Admin
diff --git a/posts.go b/posts.go
index 37c47e4..af4a215 100644
--- a/posts.go
+++ b/posts.go
@@ -130,8 +130,9 @@ func serveIndex(path string, sec *section, tax *taxonomy, taxonomyValue string,
title = sec.Title
description = sec.Description
} else if tax == nil && sec == nil {
- title = appConfig.Blog.Title
- description = appConfig.Blog.Description
+ // Show no title or description on home
+ // title = appConfig.Blog.Title
+ // description = appConfig.Blog.Description
}
// Check if feed
if ft != NONE {
diff --git a/render.go b/render.go
index bbfe8d3..3e9b513 100644
--- a/render.go
+++ b/render.go
@@ -16,6 +16,7 @@ const templateRedirect = "redirect"
const templateIndex = "index"
const templateSummary = "summary"
const templateTaxonomy = "taxonomy"
+const templateMenu = "menu"
var templates map[string]*template.Template
var templateFunctions template.FuncMap
@@ -25,6 +26,14 @@ func initRendering() {
"blog": func() *configBlog {
return appConfig.Blog
},
+ "menu": func(id string) *menu {
+ for _, m := range appConfig.Blog.Menus {
+ if m.Id == id {
+ return m
+ }
+ }
+ return nil
+ },
"md": func(content string) template.HTML {
htmlContent, err := renderMarkdown(content)
if err != nil {
@@ -64,7 +73,7 @@ func initRendering() {
}
templates = make(map[string]*template.Template)
- for _, name := range []string{templatePost, templateError, templateRedirect, templateIndex, templateSummary, templateTaxonomy} {
+ for _, name := range []string{templatePost, templateError, templateRedirect, templateIndex, templateSummary, templateTaxonomy, templateMenu} {
templates[name] = loadTemplate(name)
}
}
diff --git a/templates/base.gohtml b/templates/base.gohtml
index 145f6a9..64c7bbc 100644
--- a/templates/base.gohtml
+++ b/templates/base.gohtml
@@ -6,5 +6,10 @@
{{ template "title" . }}
+
+
+ {{ with blog.Description }}{{ . }}
{{ end }}
+ {{ include "menu" . }}
+
{{ template "main" . }}
{{ end }}
\ No newline at end of file
diff --git a/templates/menu.gohtml b/templates/menu.gohtml
new file mode 100644
index 0000000..ce78298
--- /dev/null
+++ b/templates/menu.gohtml
@@ -0,0 +1,11 @@
+{{ define "menu" }}
+
+ {{ with menu "main" }}
+ {{ $first := true }}
+ {{ range $i, $item := .Items }}
+ {{ if ne $first true }} • {{ end }}{{ $item.Title }} {{ $first = false }}
+ {{ end }}
+ {{ end }}
+
+{{ end }}
\ No newline at end of file