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

github.com/parsiya/Hugo-Octopress.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParsia Hakimian <parsiya@users.noreply.github.com>2017-05-21 20:34:46 +0300
committerGitHub <noreply@github.com>2017-05-21 20:34:46 +0300
commitb6f92d9b09c5b809b45b1087310280d37c8c7995 (patch)
tree43207081d66b8ea7bcf2025bcbabc2152cea14c5
parent6ffea31b9887d197fbfdcf1d0a48246a66df0100 (diff)
Fix isset (#37)
Fixes #35. * Fix isset for 404. notFoundHeader and notFoundText should customize 404 again. * Fix isset issue "continue reading." continueReadingText should customize it again. * Fix isset issue for sidebarMenuHeader and general sidebar cleanup. * The isset for toc is working properly because everything is lower case. * Although tags had no issues with isset (it is alwaus lowercase) I switched it to with anyways. However, .Params.tags is not visible inside so I had to use scratch * Removed isset and used "with" for tag pages.
-rw-r--r--layouts/404.html8
-rw-r--r--layouts/index.html4
-rw-r--r--layouts/indexes/category.html9
-rw-r--r--layouts/indexes/tag.html11
-rw-r--r--layouts/partials/sidebar.html8
-rw-r--r--layouts/post/single.html1
6 files changed, 24 insertions, 17 deletions
diff --git a/layouts/404.html b/layouts/404.html
index 410b0fa..7d16e3b 100644
--- a/layouts/404.html
+++ b/layouts/404.html
@@ -8,16 +8,16 @@
<article role="article">
<header>
<h1 class="entry-title">
- {{ if isset .Site.Params "notFoundHeader" }}
- {{ .Site.Params.notFoundHeader | markdownify }}
+ {{ with .Site.Params.notFoundHeader }}
+ {{ . | markdownify }}
{{ else }}
Not Found
{{ end }}
</h1>
</header>
<div id="blog-archives" class="category">
- {{ if isset .Site.Params "notFoundText" }}
- {{ .Site.Params.notFoundText | markdownify }}
+ {{ with .Site.Params.notFoundText }}
+ {{ . | markdownify }}
{{ else }}
Please either go back or use the navigation/sidebar menus.
{{ end }}
diff --git a/layouts/index.html b/layouts/index.html
index 5b587a8..bdceb5d 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -15,14 +15,14 @@
{{ else if .Description }}
{{ .Description }}
<footer>
- <a href="{{ .Permalink }}" rel="full-article">{{ if isset .Site.Params "continueReadingText" }}{{ .Site.Params.continueReadingText }} &rarr;{{ else }}Read On &rarr;{{ end }}</a>
+ <a href="{{ .Permalink }}" rel="full-article">{{ with .Site.Params.continueReadingText }}{{ . }}{{ else }}Read On{{ end }} &rarr;</a>
</footer>
{{ else }}
<p>{{ .Summary }}</p>
{{ if .Truncated }}
<footer>
- <a href="{{ .Permalink }}" rel="full-article">{{ if isset .Site.Params "continueReadingText" }}{{ .Site.Params.continueReadingText }} &rarr;{{ else }}Read On &rarr;{{ end }}</a>
+ <a href="{{ .Permalink }}" rel="full-article">{{ with .Site.Params.continueReadingText }}{{ . }}{{ else }}Read On{{ end }} &rarr;</a>
</footer>
{{ end }}
diff --git a/layouts/indexes/category.html b/layouts/indexes/category.html
index 52453f0..d928c2f 100644
--- a/layouts/indexes/category.html
+++ b/layouts/indexes/category.html
@@ -28,8 +28,11 @@
<footer>
<span class="categories"> <!-- show tags -->
tags:
- {{ if isset .Params "categories" }}
- {{ range .Params.tags }} <a class="category" href="{{ "/tags/" | absURL }}{{ . | urlize | lower }}">{{ . }}</a>{{ end }}
+ <!-- although tags had no issues with isset (it is alwaus lowercase) I switched it to with anyways.
+ However, .Params.tags is not visible inside so I had to use scratch -->
+ {{ $.Scratch.Set "tags" .Params.tags }}
+ {{ with .Params.categories }}
+ {{ range ($.Scratch.Get "tags") }} <a class="category" href="{{ "/tags/" | absURL }}{{ . | urlize | lower }}">{{ . }}</a>{{ end }}
{{ end }}
</span>
</footer>
@@ -43,4 +46,4 @@
</div>
</div>
-{{ partial "footer.html" . }} \ No newline at end of file
+{{ partial "footer.html" . }}
diff --git a/layouts/indexes/tag.html b/layouts/indexes/tag.html
index e688005..dce2ed4 100644
--- a/layouts/indexes/tag.html
+++ b/layouts/indexes/tag.html
@@ -27,14 +27,17 @@
</time>
<footer>
<span class="categories"> <!-- show categories and tags -->
- {{ if isset .Params "categories" }}
+ {{ $.Scratch.Set "cats" .Params.categories }}
+ {{ with .Params.categories }}
posted in:
- {{ range .Params.categories }} <a class="category" href="{{ "/categories/" | absURL }}{{ . | urlize | lower }}">{{ . }}</a>{{ end }}
+ {{ range ($.Scratch.Get "cats") }} <a class="category" href="{{ "/categories/" | absURL }}{{ . | urlize | lower }}">{{ . }}</a>{{ end }}
</br>
{{ end }}
- {{ if isset .Params "tags" }}
+
+ {{ $.Scratch.Set "tags" .Params.tags }}
+ {{ with .Params.tags }}
tags:
- {{ range .Params.tags }} <a class="category" href="{{ "/tags/" | absURL }}{{ . | urlize | lower }}">{{ . }}</a>{{ end }}
+ {{ range ($.Scratch.Get "tags") }} <a class="category" href="{{ "/tags/" | absURL }}{{ . | urlize | lower }}">{{ . }}</a>{{ end }}
{{ end }}
</span>
</footer>
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index 4544c89..c0968b8 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -47,8 +47,8 @@
{{ with .Site.Params.sidebarMenuEnabled }}
{{ if eq . true }}
<section class="odd">
- {{ if isset $.Site.Params "sidebarMenuHeader" }}
- <h1>{{ $.Site.Params.sidebarMenuHeader }}</h1>
+ {{ with $.Site.Params.sidebarMenuHeader }}
+ <h1>{{ . }}</h1>
{{ end }}
{{ range $.Site.Menus.sidebar }}
<li>
@@ -62,11 +62,11 @@
<!-- add recent posts - limit is .Site.Params.sidebarRecentLimit - example copied from https://gohugo.io/templates/go-templates/ -->
<!-- only display this section if sideBarRecentLimit is not zero -->
{{ with .Site.Params.sidebarRecentLimit }}
- {{ if not (eq $.Site.Params.sidebarRecentLimit 0) }}
+ {{ if not (eq . 0) }}
<section class="even">
<h1>Recent Posts</h1>
<ul id="recent_posts">
- {{ range first $.Site.Params.sidebarRecentLimit $.Site.Pages }}
+ {{ range first . $.Site.Pages }}
<li class="post">
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</li>
diff --git a/layouts/post/single.html b/layouts/post/single.html
index 6e4de67..994cbd7 100644
--- a/layouts/post/single.html
+++ b/layouts/post/single.html
@@ -11,6 +11,7 @@
<div class="entry-content">
<!-- insert table of contents if it is set either in the config file or in the frontmatter - frontmatter has priority -->
{{ $.Scratch.Set "pagetoc" .TableOfContents }}
+ <!-- the isset here is working properly becasue everything is lower case -->
{{ if or (and (isset .Params "toc") (eq .Params.toc true)) (and (not (isset .Params "toc")) (eq .Site.Params.tableOfContents true)) }}
{{ $.Scratch.Get "pagetoc" }}
{{ end }}