Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/vaga/hugo-theme-m10c.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien CASTERS <fabien@vaga.io>2020-07-16 21:57:33 +0300
committerFabien <vaga@users.noreply.github.com>2020-10-08 13:24:48 +0300
commit143e072fa91595d85dda9b16859edaa56d35528e (patch)
tree1360b65163e3c99d17fd01f30218e1062b40f92b
parent476c36d260427d1b7a0aab768af18021db240cda (diff)
Add custom menu
-rw-r--r--README.md11
-rw-r--r--exampleSite/config.toml6
-rw-r--r--layouts/_default/baseof.html8
-rw-r--r--layouts/_default/list.html7
-rw-r--r--layouts/_default/single.html14
5 files changed, 38 insertions, 8 deletions
diff --git a/README.md b/README.md
index 93f0a3a..6e1135a 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,17 @@ In your `config.toml` file, define the following variables in `params`:
- `description`: Short description of the author
- `avatar`: Path of file containing the author avatar image
+To add a menu item, add the following lines in `menu`:
+
+```
+[[menu.main]]
+ identifier = "tags"
+ name = "Tags"
+ url = "/tags/"
+```
+
+[Read Hugo documentations](https://gohugo.io/content-management/menus/#readout) for more informations about menu
+
To add a social link, add the following lines in `params`:
```
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 42eb189..1708f19 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -4,6 +4,12 @@ themesDir = "../.."
theme = "m10c"
paginate = 5
+[menu]
+ [[menu.main]]
+ identifier = "tags"
+ name = "Tags"
+ url = "/tags/"
+
[params]
author = "John Doe"
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vehicula turpis sit amet elit pretium."
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 36a1b31..923d10e 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -19,6 +19,14 @@
<header class="app-header">
<a href="{{ .Site.BaseURL }}"><img class="app-header-avatar" src="{{ .Site.Params.avatar | default "avatar.jpg" | relURL }}" alt="{{ .Site.Params.author | default "John Doe" }}" /></a>
<h1>{{ .Site.Title }}</h1>
+ {{- with .Site.Menus.main }}
+ <nav class="app-header-menu">
+ -
+ {{- range . }}
+ <a href="{{ .URL }}">{{ .Name }}</a> -
+ {{- end }}
+ </nav>
+ {{- end }}
<p>{{ .Site.Params.description | default "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vehicula turpis sit amet elit pretium." }}</p>
<div class="app-header-social">
{{ range .Site.Params.social }}
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 392c5e2..8a0c7c7 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -2,12 +2,15 @@
<article>
<h1>{{ .Title }}</h1>
<ul class="posts-list">
- {{ range $index, $element := .Paginator.Pages }}
+ {{ range where .Paginator.Pages "Type" "!=" "page" }}
<li class="posts-list-item">
<a class="posts-list-item-title" href="{{ .Permalink }}">{{ .Title }}</a>
<span class="posts-list-item-description">
- {{ partial "icon.html" (dict "ctx" $ "name" "clock") }} {{ .ReadingTime }} min read -
+ {{ partial "icon.html" (dict "ctx" $ "name" "calendar") }}
{{ .PublishDate.Format "Jan 2, 2006" }}
+ -
+ {{ partial "icon.html" (dict "ctx" $ "name" "clock") }}
+ {{ .ReadingTime }} min read
</span>
</li>
{{ end }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 8dcd8cc..30da500 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -2,6 +2,7 @@
<article class="post">
<header class="post-header">
<h1 class ="post-title">{{ .Title }}</h1>
+ {{- if ne .Type "page" }}
<div class="post-meta">
<div>
{{ partial "icon.html" (dict "ctx" $ "name" "calendar") }}
@@ -11,17 +12,18 @@
{{ partial "icon.html" (dict "ctx" $ "name" "clock") }}
{{ .ReadingTime }} min read
</div>
- {{- with .Params.tags -}}
+ {{- with .Params.tags }}
<div>
{{ partial "icon.html" (dict "ctx" $ "name" "tag") }}
- {{ range . -}}
- {{- with $.Site.GetPage (printf "/%s/%s" "tags" . ) -}}
+ {{- range . -}}
+ {{ with $.Site.GetPage (printf "/%s/%s" "tags" . ) }}
<a class="tag" href="{{ .Permalink }}">{{ .Title }}</a>
- {{- end -}}
- {{- end -}}
+ {{- end }}
+ {{- end }}
</div>
- {{- end -}}
+ {{- end }}
</div>
+ {{- end }}
</header>
<div class="post-content">
{{ .Content }}