forked from ohayo-jacob/takunomi-blog
made menu prettier. code is ugly though
This commit is contained in:
parent
767f6a650b
commit
ee552b5bf3
|
@ -14,9 +14,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<ul id="menu">
|
<ul id="menu">
|
||||||
{{range .MenuItems}}
|
<li><a class={{if eq .CurrentPage "about"}}"menuselect menuElement no-link"{{else}}"menuElement no-link"{{end}} href="/about">about</a></li>
|
||||||
<li>{{ . }}</li>{{else}}<div><strong>no rows</strong></div>{{end}}
|
<li><a class={{if eq .CurrentPage "past"}}"menuselect menuElement no-link"{{else}}"menuElement no-link"{{end}} href="/past">past</a></li>
|
||||||
</ul>
|
<li><a class={{if eq .CurrentPage "contact"}}"menuselect menuElement no-link"{{else}}"menuElement no-link"{{end}} href="/contact">contact</a></li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="contents">
|
<div class="contents">
|
||||||
{{if eq .CurrentPage "blog"}}
|
{{if eq .CurrentPage "blog"}}
|
||||||
|
|
10
style.tmpl
10
style.tmpl
|
@ -83,11 +83,17 @@ ul {
|
||||||
.menu{
|
.menu{
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding-bottom: 40px;
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuselect{
|
||||||
|
background-color: #687fad;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menuElement{
|
.menuElement{
|
||||||
padding: 20px
|
border: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menuElement:hover {
|
.menuElement:hover {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
//Page : Is exported to PostCollection
|
//Page : Is exported to PostCollection
|
||||||
type Page struct {
|
type Page struct {
|
||||||
Title string
|
Title string
|
||||||
MenuItems []template.HTML
|
|
||||||
Posts []Post
|
Posts []Post
|
||||||
CurrentPage string
|
CurrentPage string
|
||||||
}
|
}
|
||||||
|
@ -19,11 +18,6 @@ type Page struct {
|
||||||
var style = ``
|
var style = ``
|
||||||
var name = "takunomi"
|
var name = "takunomi"
|
||||||
var posts []Post
|
var posts []Post
|
||||||
var sections = []template.HTML{
|
|
||||||
`<a class="no-link menuElement" style="text-decoration: none; color: inherit" href=/about>about</a>`,
|
|
||||||
`<a class="no-link menuElement" style="text-decoration: none; color: inherit" href=/past>past</a>`,
|
|
||||||
`<a class="no-link menuElement" style="text-decoration: none; color: inherit" href=/contact>contact</a>`,
|
|
||||||
}
|
|
||||||
var templates = template.Must(template.ParseFiles("blog.tmpl", "about.tmpl", "past.tmpl", "contact.tmpl", "blog_roll.tmpl", "style.tmpl", "post.tmpl"))
|
var templates = template.Must(template.ParseFiles("blog.tmpl", "about.tmpl", "past.tmpl", "contact.tmpl", "blog_roll.tmpl", "style.tmpl", "post.tmpl"))
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -59,29 +53,29 @@ func blogHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
posts = getNewestPosts(3)
|
posts = getNewestPosts(3)
|
||||||
page := Page{name, sections, posts, "blog"}
|
page := Page{name, posts, "blog"}
|
||||||
renderTemplates(w, page)
|
renderTemplates(w, page)
|
||||||
}
|
}
|
||||||
|
|
||||||
func postHandler(w http.ResponseWriter, r *http.Request) {
|
func postHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
title := strings.TrimPrefix(r.URL.Path, "/post/")
|
title := strings.TrimPrefix(r.URL.Path, "/post/")
|
||||||
posts := []Post{getPostByURLTitle(title)}
|
posts := []Post{getPostByURLTitle(title)}
|
||||||
page := Page{name, sections, posts, "blog"}
|
page := Page{name, posts, "blog"}
|
||||||
renderTemplates(w, page)
|
renderTemplates(w, page)
|
||||||
}
|
}
|
||||||
|
|
||||||
func aboutHandler(w http.ResponseWriter, r *http.Request) {
|
func aboutHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
page := Page{name, sections, []Post{}, "about"}
|
page := Page{name, []Post{}, "about"}
|
||||||
renderTemplates(w, page)
|
renderTemplates(w, page)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pastHandler(w http.ResponseWriter, r *http.Request) {
|
func pastHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
page := Page{name, sections, posts, "past"}
|
page := Page{name, posts, "past"}
|
||||||
renderTemplates(w, page)
|
renderTemplates(w, page)
|
||||||
}
|
}
|
||||||
|
|
||||||
func contactHandler(w http.ResponseWriter, r *http.Request) {
|
func contactHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
page := Page{name, sections, []Post{}, "contact"}
|
page := Page{name, []Post{}, "contact"}
|
||||||
renderTemplates(w, page)
|
renderTemplates(w, page)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user