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:
authorDionysis Grigoropoulos <dgrig@erethon.com>2016-05-26 00:44:09 +0300
committerDionysis Grigoropoulos <dgrig@erethon.com>2016-05-26 09:06:33 +0300
commit3f7f37851c5482b06a89456b80710cf39382b042 (patch)
tree5586daa6a0cdb6c2987cf75b83522da840a831c9
parentbcd9bcd32cc2810858c223c3f316420eb1b49795 (diff)
Create a partial template for the header of posts
* Move duplicate code that handles the header/title of a post in a partial template. * Format code a bit.
-rw-r--r--layouts/index.html16
-rw-r--r--layouts/partials/post_header.html18
-rw-r--r--layouts/post/single.html12
3 files changed, 21 insertions, 25 deletions
diff --git a/layouts/index.html b/layouts/index.html
index 0598df7..c44ebf9 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -6,20 +6,8 @@
{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
{{ range $paginator.Pages }}
<article>
- <header>
- <h1 class="entry-title">
- <a href="{{ .Permalink }}">{{ .Title }}</a>
- </h1>
- <p class="meta">{{ .Date.Format "Jan 2, 2006" }} - {{ .ReadingTime }} minute read - {{ if .Site.Params.disqusShortname }} <a href="{{ .Permalink }}#disqus_thread">Comments</a>{{ end }}
- {{ if isset .Params "categories" }}
- <!-- <br/> this will make the categories go to the second line and mess with the title -->
- <!-- in order to make category URLs work, we need to urlize them and then convert them to lowercase
- e.g. .NET Remoting -urlize-> .NET-Remoting -lowercase-> .net-remoting -->
- {{ range .Params.categories }}<a class="label" href="{{ "/categories/" | absURL }}{{ . | urlize | lower }}/">{{ . }}</a>{{ end }}
- {{ end }}</p>
-
- </header>
+ {{ partial "post_header.html" . }}
{{ if eq .Site.Params.truncate false }}
{{ .Content }}
@@ -50,4 +38,4 @@
</div>
</div>
-{{ partial "footer.html" . }} <!-- footer --> \ No newline at end of file
+{{ partial "footer.html" . }} <!-- footer -->
diff --git a/layouts/partials/post_header.html b/layouts/partials/post_header.html
new file mode 100644
index 0000000..3868f4f
--- /dev/null
+++ b/layouts/partials/post_header.html
@@ -0,0 +1,18 @@
+<!-- This file contains the header/title for each post -->
+
+<header>
+ <h1 class="entry-title">
+ {{ if .IsHome }} <a href="{{ .Permalink }}">{{ .Title }}</a> {{ else }} {{ .Title }} {{ end }}
+ </h1>
+ <p class="meta">{{ .Date.Format "Jan 2, 2006" }}
+ - {{ .ReadingTime }} minute read
+ {{ if .Site.Params.disqusShortname }} - <a href="{{ .Permalink }}#disqus_thread">Comments</a>{{ end }}
+
+ {{ if isset .Params "categories" }}
+ <!-- <br/> this will make the categories go to the second line and mess with the title -->
+ <!-- in order to make category URLs work, we need to urlize them and then convert them to lowercase
+ e.g. .NET Remoting -urlize-> .NET-Remoting -lowercase-> .net-remoting -->
+ - {{ range .Params.categories }}<a class="label" href="{{ "/categories/" | absURL }}{{ . | urlize | lower }}/">{{ . }}</a>{{ end }}
+ {{ end }}
+ </p>
+</header>
diff --git a/layouts/post/single.html b/layouts/post/single.html
index 2e843f3..d61ba0d 100644
--- a/layouts/post/single.html
+++ b/layouts/post/single.html
@@ -4,19 +4,9 @@
<div id="content">
<div>
<article class="hentry" role="article">
- <header>
- <h1 class="entry-title">
- {{ .Title }} <!-- we don't need page title to be a link on the actual page -->
- </h1>
- <p class="meta">{{ .Date.Format "Jan 2, 2006" }} - {{ .ReadingTime }} minute read - {{ if .Site.Params.disqusShortname }} <a href="{{ .Permalink }}#disqus_thread">Comments</a>{{ end }}
- <!-- if you want anything in the header between Disqus comments and categories add them here -->
+ {{ partial "post_header.html" . }}
- {{ if isset .Params "categories" }}
- <!-- <br/> this will make the categories go to the second line and mess with the title -->
- {{ range .Params.categories }}<a class="label" href="{{ "/categories/" | absURL }}{{ . | urlize | lower }}">{{ . }}</a>{{ end }}
- {{ end }}</p>
- </header>
<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 }}