Skip to content

Commit

Permalink
Merge pull request #37 from bwangel23/add_tags_page
Browse files Browse the repository at this point in the history
添加了标签页 V2
  • Loading branch information
laozhu authored Nov 28, 2017
2 parents 1e550b2 + 3e94a92 commit fb64a31
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ The hugo-nuo theme add `home` and `works` page to initial site menu, you can add
weight = 20
identifier = "works"
url = "https://github.com/laozhu"

[[menu.main]]
name = "Tags"
weight = 30
identifier = "tags"
url = "/tags"
```

Or you can add some other page to menu in page's front matter:
Expand Down
6 changes: 6 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ copyright = "© This post is licensed under a Creative Commons Attribution-NonCo
identifier = "works"
url = "https://github.com/laozhu"

[[menu.main]]
name = "Tags"
weight = 30
identifier = "tags"
url = "/tags"

# Add your own params here
[params]
author = "Ritchie Zhu"
Expand Down
21 changes: 21 additions & 0 deletions layouts/_default/terms.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ define "title" }}
{{ if isset .Site.Params "seotitle" }}{{ .Site.Params.seotitle }}{{ else }}{{ .Site.Title }}{{ end }}
→ Tags
{{ end }}

{{ define "main" }}
{{ partial "header.html" . }}
<section class="main term-list">
{{ $data := .Data }}
<header class="term-header">
<h2>Tags</h2>
</header>

<div class="term-tags">
{{ range $key,$value := .Data.Terms.ByCount }}
<a href="/{{ $data.Plural }}/{{ $value.Name | urlize }}" style="font-size: {{ add (mul $value.Count 3.17) 12.83 }}px;"> {{ $value.Name }}</a>
{{ end }}
</div>
</section>
{{ partial "footer.html" . }}
{{ end }}
13 changes: 12 additions & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ <h2 class="offscreen">Main Menu</h2>
{{ $kind := .Kind }}
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
<li class="menu-item {{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} is-active{{ end }}{{ if and (eq .Identifier "home") (eq $type "post") }} is-active{{ end }}{{ if and (eq .Identifier "home") (and (eq $type "page") (eq $kind "taxonomy"))}} is-active{{ end }}"><a href="{{ .URL }}">{{ .Name }}</a></li>
<li class="menu-item
{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}
is-active
{{ end }}
{{ if and (eq .Identifier "tags") (and (eq $type "page") (or (eq $kind "taxonomyTerm") (eq $kind "taxonomy"))) }}
is-active
{{ end }}
{{ if and (eq .Identifier "home") (eq $type "post") }}
is-active
{{ end }}">
<a href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
</nav>
Expand Down
1 change: 1 addition & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
@import 'partials/syntax';
@import 'partials/links';
@import 'partials/misc';
@import 'partials/terms';
25 changes: 25 additions & 0 deletions src/styles/partials/terms.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.term-list {
.term-header {
h2 {
font-size: 48px;
}
}
.term-tags {
max-width: 60em;
margin: 2em auto;
margin-top: 0em;
a {
margin-right: 1em;
line-height: 65px;
border-bottom: 1px solid gray;
white-space: nowrap;
transition: border-bottom .5s;

&:hover {
border-bottom: 3px dotted gray;
text-decoration: none;
color: #404040;
}
}
}
}
2 changes: 1 addition & 1 deletion static/css/bundle.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions static/css/bundle.css.map

Large diffs are not rendered by default.

0 comments on commit fb64a31

Please sign in to comment.