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

github.com/shaform/hugo-theme-den.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaform <shaform@gmail.com>2018-07-26 15:58:48 +0300
committerShaform <shaform@gmail.com>2018-07-26 15:58:48 +0300
commit8912374cfe804d9741efca352a50be1bad5f5e92 (patch)
tree0df69e781a0200c2aae695aab8f95c173b4f229a
parent8b88b2b9f25b05919d81fec5ab711f9a6f68dd89 (diff)
support links added via frontmatter
-rw-r--r--exampleSite/config.toml10
-rw-r--r--exampleSite/content/en/about.md2
-rw-r--r--exampleSite/content/zh-tw/about.md2
-rw-r--r--layouts/partials/header.html12
4 files changed, 12 insertions, 14 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index ae77fa5..81f6fe9 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -121,11 +121,6 @@ defaultContentLanguageInSubdir = true
weight = 20
identifier = "demos"
url = "category/demos/"
- [[languages.en.menu.main]]
- name = "About"
- weight = 30
- identifier = "about"
- url = "about/"
[[languages.en.menu.social]]
name = "GitHub"
@@ -158,11 +153,6 @@ defaultContentLanguageInSubdir = true
weight = 20
identifier = "demos"
url = "category/demos/"
- [[languages.zh-tw.menu.main]]
- name = "關於"
- weight = 30
- identifier = "about"
- url = "about/"
[[languages.zh-tw.menu.social]]
name = "GitHub"
diff --git a/exampleSite/content/en/about.md b/exampleSite/content/en/about.md
index 0de515f..6ca684d 100644
--- a/exampleSite/content/en/about.md
+++ b/exampleSite/content/en/about.md
@@ -2,6 +2,8 @@
title: "About"
date: 2017-08-20T21:38:52+08:00
lastmod: 2017-08-28T21:41:52+08:00
+menu: "main"
+weight: 50
---
Hugo is a static site engine written in Go.
diff --git a/exampleSite/content/zh-tw/about.md b/exampleSite/content/zh-tw/about.md
index 84ab2a6..de9c9de 100644
--- a/exampleSite/content/zh-tw/about.md
+++ b/exampleSite/content/zh-tw/about.md
@@ -2,6 +2,8 @@
title: "關於"
date: 2017-08-20T21:38:52+08:00
lastmod: 2017-08-28T21:41:52+08:00
+menu: "main"
+weight: 50
---
Hugo 是個靜態網頁產生器。
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 1f4013c..30bfc41 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -19,12 +19,16 @@
</button>
<div class="nav-menu collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
- {{ range .Site.Menus.main }}
+ {{ range $index, $menuItem := .Site.Menus.main }}
<li class="nav-item">
- {{ if hasPrefix .URL "http" }}
- <a class="nav-link" href="{{ .URL | safeURL }}">{{ with .Pre }}{{ . | safeHTML }}{{ end }}{{ .Name }}</a>
+ {{ with $menuItem.Page }}
+ <a class="nav-link" href="{{ .Permalink }}">{{ with $menuItem.Pre }}{{ . | safeHTML }}{{ end }}{{ $menuItem.Name }}</a>
{{ else }}
- <a class="nav-link" href="{{ .URL | absLangURL | safeURL }}">{{ with .Pre }}{{ . | safeHTML }}{{ end }}{{ .Name }}</a>
+ {{ if hasPrefix .URL "http" }}
+ <a class="nav-link" href="{{ .URL | safeURL }}">{{ with $menuItem.Pre }}{{ . | safeHTML }}{{ end }}{{ $menuItem.Name }}</a>
+ {{ else }}
+ <a class="nav-link" href="{{ .URL | absLangURL | safeURL }}">{{ with $menuItem.Pre }}{{ . | safeHTML }}{{ end }}{{ $menuItem.Name }}</a>
+ {{ end }}
{{ end }}
</li>
{{ end }}