From 8528dbcf317aa3cea0820a5e465357f08321deda Mon Sep 17 00:00:00 2001 From: Lukas Herman Date: Fri, 27 Jul 2018 18:05:01 -0400 Subject: Added multiple writers support to single page layout --- layouts/_default/single.html | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 7c9d6d4..292b193 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,10 +1,12 @@ {{ define "body" }} - {{ end }} +{{ end }} - {{ define "main" }} +{{ define "main" }} + {{ $has_writer := isset .Site.Params.writers (lower .Params.writer) }} + {{ $writer := index .Site.Params.writers (lower .Params.writer) | default dict }}
{{ if and (isset .Params "image") .Params.image }}
@@ -20,10 +22,8 @@ {{ .Date.Format "02 January" }} / - {{ if and (isset .Site.Params "authorlink") .Site.Params.authorLink }} - - {{ else }} - {{ .Site.Params.author | default "" }} + {{ if $has_writer }} + {{ end }} @@ -77,22 +77,22 @@ {{ end }}

-{{ if and (isset .Site.Params "author") .Site.Params.author }} +{{ if $has_writer }}
- {{ range .Site.Params.bio }} + {{ range $writer.bio }}

{{ . | default "" | safeHTML }}

{{ end }} - {{ with .Site.Params.social.facebook }} + {{ with $writer.facebook }} {{end}} -{{ with .Site.Params.social.linkedin }} +{{ with $writer.linkedin }} {{end}} -{{ with .Site.Params.social.email }} +{{ with $writer.email }} {{end}} -{{ with .Site.Params.social.instagram }} +{{ with $writer.instagram }} {{end}} -{{ with .Site.Params.social.stackoverflow }} +{{ with $writer.stackoverflow }} {{end}} -{{ with .Site.Params.social.github }} +{{ with $writer.github }} {{end}} -{{ with .Site.Params.social.pinterest }} +{{ with $writer.pinterest }} Date: Fri, 27 Jul 2018 18:29:10 -0400 Subject: Added multiple writers support to portfolio --- layouts/partials/portfolio.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/layouts/partials/portfolio.html b/layouts/partials/portfolio.html index 42a8650..9b44653 100644 --- a/layouts/partials/portfolio.html +++ b/layouts/partials/portfolio.html @@ -3,6 +3,8 @@
{{ $paginator := .Paginate (where (where .Site.Pages "Type" "post") "IsPage" true) }} {{ range $index, $element := .Paginator.Pages }} + {{ $has_writer := isset .Site.Params.writers (lower .Params.writer) }} + {{ $writer := index .Site.Params.writers (lower .Params.writer) | default dict }} {{ if and (isset .Params "image") .Params.image }} {{ if eq (mod $index 2) 0 }}
@@ -23,14 +25,10 @@
{{ .Date.Format "02 January" }} / - {{ if and (isset .Site.Params "author") .Site.Params.author }} + {{ if $has_writer }} - {{ if and (isset .Site.Params "authorlink") .Site.Params.authorLink }} - - {{ else }} - {{ .Site.Params.author | default "" }} - {{ end }} + {{ end }} -- cgit v1.2.3 From 56d7b109f61b74270ace67537af454a3bef7a4e8 Mon Sep 17 00:00:00 2001 From: Lukas Herman Date: Fri, 27 Jul 2018 18:51:49 -0400 Subject: Updated examples with multiple writers feature --- exampleSite/config.toml | 27 ++++++++++++++++++++++++++- exampleSite/content/post/work1.md | 1 + exampleSite/content/post/work10.md | 1 + exampleSite/content/post/work11.md | 1 + exampleSite/content/post/work2.md | 1 + exampleSite/content/post/work3.md | 1 + exampleSite/content/post/work4.md | 1 + exampleSite/content/post/work5.md | 1 + exampleSite/content/post/work7.md | 1 + exampleSite/content/post/work8.md | 1 + exampleSite/content/post/work9.md | 1 + 11 files changed, 36 insertions(+), 1 deletion(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index bfe0c90..168c5fd 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -64,4 +64,29 @@ paginate = 5 #frontpage pagination instagram = "full profile url in instagram" github = "full profile url in github" pinterest = "full profile url in pinterest" - rss = true \ No newline at end of file + rss = true + + [params.writers] + [params.writers."Lukas Herman"] + link = "https://lherman.tk" + email = "writer_email@example.com" + facebook = "full profile url in facebook" + googleplus = "full profile url in googleplus" + twitter = "full profile url in twitter" + linkedin = "full profile url in linkedin" + stackoverflow = "full profile url in stackoverflow" + instagram = "full profile url in instagram" + github = "full profile url in github" + pinterest = "full profile url in pinterest" + + [params.writers."Göran Svensson"] + link = "https://appernetic.io/" + email = "writer_email@example.com" + facebook = "full profile url in facebook" + googleplus = "full profile url in googleplus" + twitter = "full profile url in twitter" + linkedin = "full profile url in linkedin" + stackoverflow = "full profile url in stackoverflow" + instagram = "full profile url in instagram" + github = "full profile url in github" + pinterest = "full profile url in pinterest" \ No newline at end of file diff --git a/exampleSite/content/post/work1.md b/exampleSite/content/post/work1.md index 7b1d704..6f4a5cf 100644 --- a/exampleSite/content/post/work1.md +++ b/exampleSite/content/post/work1.md @@ -4,6 +4,7 @@ draft = false image = "img/portfolio/a4-paper.jpg" date = "2016-11-05T18:25:22+05:30" title = "Name of the work 1" +writer = "Göran Svensson" weight = 0 +++ diff --git a/exampleSite/content/post/work10.md b/exampleSite/content/post/work10.md index 20e9ab7..2687c8e 100644 --- a/exampleSite/content/post/work10.md +++ b/exampleSite/content/post/work10.md @@ -4,6 +4,7 @@ image = "img/portfolio/trifold.jpg" showonlyimage = true date = "2016-11-05T20:22:08+05:30" title = "Item with image" +writer = "Göran Svensson" weight = 10 +++ diff --git a/exampleSite/content/post/work11.md b/exampleSite/content/post/work11.md index 17c6117..02bfb41 100644 --- a/exampleSite/content/post/work11.md +++ b/exampleSite/content/post/work11.md @@ -4,6 +4,7 @@ image = "img/portfolio/paper-presentation.jpg" showonlyimage = true date = "2016-11-05T20:23:59+05:30" title = "Item with image" +writer = "Göran Svensson" weight = 11 +++ diff --git a/exampleSite/content/post/work2.md b/exampleSite/content/post/work2.md index 3826e6a..9215ab8 100644 --- a/exampleSite/content/post/work2.md +++ b/exampleSite/content/post/work2.md @@ -1,6 +1,7 @@ +++ date = "2016-11-05T19:41:01+05:30" title = "This is a Standard Post" +writer = "Göran Svensson" draft = false image = "img/portfolio/logs1.jpg" showonlyimage = false diff --git a/exampleSite/content/post/work3.md b/exampleSite/content/post/work3.md index e5cba6d..37d2ac8 100644 --- a/exampleSite/content/post/work3.md +++ b/exampleSite/content/post/work3.md @@ -3,6 +3,7 @@ image = "img/portfolio/bridge1.jpg" showonlyimage = false date = "2016-11-05T19:44:32+05:30" title = "Another Awesome Post" +writer = "Göran Svensson" categories = [ "travel" ] draft = false weight = 2 diff --git a/exampleSite/content/post/work4.md b/exampleSite/content/post/work4.md index c467c84..0982df5 100644 --- a/exampleSite/content/post/work4.md +++ b/exampleSite/content/post/work4.md @@ -4,6 +4,7 @@ image = "" showonlyimage = false date = "2016-11-05T19:50:47+05:30" title = "A post without an Image" +writer = "Göran Svensson" categories = [ "code" ] weight = 4 +++ diff --git a/exampleSite/content/post/work5.md b/exampleSite/content/post/work5.md index 5909723..48a6833 100644 --- a/exampleSite/content/post/work5.md +++ b/exampleSite/content/post/work5.md @@ -4,6 +4,7 @@ showonlyimage = true draft = false date = "2016-11-05T19:53:42+05:30" title = "A Totally Response Theme" +writer = "Göran Svensson" categories = [ "photography" ] weight = 5 +++ diff --git a/exampleSite/content/post/work7.md b/exampleSite/content/post/work7.md index eba3afd..e76bcab 100644 --- a/exampleSite/content/post/work7.md +++ b/exampleSite/content/post/work7.md @@ -3,6 +3,7 @@ image = "img/portfolio/bike1.jpg" showonlyimage = false date = "2016-11-05T19:57:40+05:30" title = "Post with a Gallery" +writer = "Göran Svensson" draft = false weight = 7 +++ diff --git a/exampleSite/content/post/work8.md b/exampleSite/content/post/work8.md index c68e697..d364df0 100644 --- a/exampleSite/content/post/work8.md +++ b/exampleSite/content/post/work8.md @@ -4,6 +4,7 @@ draft = false image = "img/portfolio/camera1.jpg" date = "2016-11-05T19:59:22+05:30" title = "A Post with lot of comments" +writer = "Göran Svensson" weight = 8 +++ diff --git a/exampleSite/content/post/work9.md b/exampleSite/content/post/work9.md index 83830a5..646101a 100644 --- a/exampleSite/content/post/work9.md +++ b/exampleSite/content/post/work9.md @@ -4,6 +4,7 @@ image = "img/portfolio/birds.jpg" showonlyimage = false date = "2016-11-05T20:02:19+05:30" title = "Blogging is Fun and Worthwhile" +writer = "Göran Svensson" weight = 9 +++ -- cgit v1.2.3 From fe6805b496689466271a05eccee7ea4663b336d5 Mon Sep 17 00:00:00 2001 From: Lukas Herman Date: Tue, 7 Aug 2018 22:09:22 -0400 Subject: Added backward compatibility --- layouts/_default/single.html | 14 ++++++++------ layouts/partials/portfolio.html | 11 +++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 292b193..8e1f1e1 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -5,8 +5,13 @@ {{ define "main" }} - {{ $has_writer := isset .Site.Params.writers (lower .Params.writer) }} - {{ $writer := index .Site.Params.writers (lower .Params.writer) | default dict }} + {{ $scratch := newScratch }} + {{ if .Site.Params.writers }} + {{ $scratch.Set "writer" (index .Site.Params.writers (lower .Params.writer) | default dict) }} + {{ else }} + {{ $scratch.Set "writer" .Site.Params.social | default dict }} + {{ end }} + {{ $writer := $scratch.Get "writer" }}
{{ if and (isset .Params "image") .Params.image }}
@@ -22,9 +27,7 @@ {{ .Date.Format "02 January" }} / - {{ if $has_writer }} - {{ end }} @@ -77,7 +80,6 @@ {{ end }}

-{{ if $has_writer }}
@@ -169,7 +171,7 @@ title="pinterest icon">
-{{ end }} +
diff --git a/layouts/partials/portfolio.html b/layouts/partials/portfolio.html index 9b44653..855792c 100644 --- a/layouts/partials/portfolio.html +++ b/layouts/partials/portfolio.html @@ -3,8 +3,13 @@
{{ $paginator := .Paginate (where (where .Site.Pages "Type" "post") "IsPage" true) }} {{ range $index, $element := .Paginator.Pages }} - {{ $has_writer := isset .Site.Params.writers (lower .Params.writer) }} - {{ $writer := index .Site.Params.writers (lower .Params.writer) | default dict }} + {{ $scratch := newScratch }} + {{ if .Site.Params.writers }} + {{ $scratch.Set "writer" (index .Site.Params.writers (lower .Params.writer) | default dict) }} + {{ else }} + {{ $scratch.Set "writer" .Site.Params.social | default dict }} + {{ end }} + {{ $writer := $scratch.Get "writer" }} {{ if and (isset .Params "image") .Params.image }} {{ if eq (mod $index 2) 0 }}
@@ -25,12 +30,10 @@
{{ .Date.Format "02 January" }} / - {{ if $has_writer }} - {{ end }} {{ range .Params.categories }} / -- cgit v1.2.3