diff options
author | tdro <tdro@noreply.example.com> | 2023-06-18 18:32:33 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-06-18 18:32:33 -0400 |
commit | 69591d98d61888c211b986bf96a36014590b4cbf (patch) | |
tree | d5e2dc71a73ea77786080ab5fb2a3878cab65b37 | |
parent | 23b45c260c734539c684df8b713c32dbea375532 (diff) | |
download | canory-69591d98d61888c211b986bf96a36014590b4cbf.tar.gz canory-69591d98d61888c211b986bf96a36014590b4cbf.tar.bz2 canory-69591d98d61888c211b986bf96a36014590b4cbf.zip |
themes/default/layouts/_default/section: Write gallery, webring, following once
Check for parent node
4 files changed, 130 insertions, 120 deletions
diff --git a/themes/default/layouts/_default/section.following.html b/themes/default/layouts/_default/section.following.html index eef5e12..7057e97 100644 --- a/themes/default/layouts/_default/section.following.html +++ b/themes/default/layouts/_default/section.following.html @@ -1,65 +1,69 @@ -{{- $sources := slice -}} -{{- $author := partial "function-authors-data.html" . -}} -{{- $feeds := partial "function-generate-feeds.html" . -}} +{{- $parent := eq (len .Page.Ancestors) 1 -}} -{{- range $author.feeds.rss -}} - {{- $data := split . " " -}} - {{- $url := delimit (first 1 $data) "" -}} - {{- $sources = $sources | append (string $url) -}} -{{- end -}} +{{- if $parent -}} + {{- $sources := slice -}} + {{- $author := partial "function-authors-data.html" . -}} + {{- $feeds := partial "function-generate-feeds.html" . -}} + + {{- range $author.feeds.rss -}} + {{- $data := split . " " -}} + {{- $url := delimit (first 1 $data) "" -}} + {{- $sources = $sources | append (string $url) -}} + {{- end -}} -{{- range $source := (first 3 (shuffle $sources)) -}} - {{- range $distinct := first 1 (where $feeds "FeedSourceLink" "eq" $source) -}} + {{- range $source := (first 3 (shuffle $sources)) -}} + {{- range $distinct := first 1 (where $feeds "FeedSourceLink" "eq" $source) -}} - {{- $href := or $distinct.FeedHome (print "http://" $distinct.FeedSourceDomain) -}} - {{- $favicon := print "/" (partial "function-paths.html").media "/favicon." (.FeedSourceLink | anchorize) ".png" -}} + {{- $href := or $distinct.FeedHome (print "http://" $distinct.FeedSourceDomain) -}} + {{- $favicon := print "/" (partial "function-paths.html").media "/favicon." (.FeedSourceLink | anchorize) ".png" -}} - <micro-author> - <micro-card> - <micro-summary> - <micro-thumbnail> - <figure> - <a - title="{{ $distinct.FeedName }}" - href="{{ $href }}"> - <picture> - <img - width="64" - height="64" - alt="{{ $distinct.FeedName }}" - src="{{ $.Site.BaseURL }}{{ $favicon }}" - /> - </picture> - </a> - </figure> - </micro-thumbnail> - <micro-header> - <h2> - <b>{{ $distinct.FeedName }}</b> - </h2> - <h3> - <a - data-hover - title="{{ $distinct.FeedName }}" - href="{{ $href }}"> - @{{ $distinct.FeedSourceDomain }} - </a> - </h3> - <time - title="{{ $distinct.FeedDateTitle }}" - datetime="{{ $distinct.FeedDateTime }}"> - {{ $distinct.FeedDateTime | time.Format "15:04 Jan 2 2006" -}} - </time> - </micro-header> - <a - title="Follow {{ $distinct.FeedName }}" - href="{{ $href }}"> - {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/rss.svg")) }} - <header>Follow</header> - </a> - </micro-summary> - </micro-card> - </micro-author> + <micro-author> + <micro-card> + <micro-summary> + <micro-thumbnail> + <figure> + <a + title="{{ $distinct.FeedName }}" + href="{{ $href }}"> + <picture> + <img + width="64" + height="64" + alt="{{ $distinct.FeedName }}" + src="{{ $.Site.BaseURL }}{{ $favicon }}" + /> + </picture> + </a> + </figure> + </micro-thumbnail> + <micro-header> + <h2> + <b>{{ $distinct.FeedName }}</b> + </h2> + <h3> + <a + data-hover + title="{{ $distinct.FeedName }}" + href="{{ $href }}"> + @{{ $distinct.FeedSourceDomain }} + </a> + </h3> + <time + title="{{ $distinct.FeedDateTitle }}" + datetime="{{ $distinct.FeedDateTime }}"> + {{ $distinct.FeedDateTime | time.Format "15:04 Jan 2 2006" -}} + </time> + </micro-header> + <a + title="Follow {{ $distinct.FeedName }}" + href="{{ $href }}"> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/rss.svg")) }} + <header>Follow</header> + </a> + </micro-summary> + </micro-card> + </micro-author> + {{- end -}} {{- end -}} {{- end -}} diff --git a/themes/default/layouts/_default/section.gallery.html b/themes/default/layouts/_default/section.gallery.html index dfa141e..4b1c6fd 100644 --- a/themes/default/layouts/_default/section.gallery.html +++ b/themes/default/layouts/_default/section.gallery.html @@ -1 +1,5 @@ -{{- partial "gallery-walk.html" . -}} +{{- $parent := eq (len .Page.Ancestors) 1 -}} + +{{- if $parent -}} + {{- partial "gallery-walk.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/section.webring.html b/themes/default/layouts/_default/section.webring.html index 59b26ba..878ad95 100644 --- a/themes/default/layouts/_default/section.webring.html +++ b/themes/default/layouts/_default/section.webring.html @@ -1,57 +1,59 @@ -{{- $items := slice -}} -{{- $sources := slice -}} -{{- $author := partial "function-authors-data.html" . -}} -{{- $feeds := partial "function-generate-feeds.html" . -}} +{{- $parent := eq (len .Page.Ancestors) 1 -}} -{{- range $author.feeds.rss -}} - {{- $data := split . " " -}} - {{- $url := delimit (first 1 $data) "" -}} - {{- $sources = $sources | append (string $url) -}} -{{- end -}} +{{- if $parent -}} + {{- $items := slice -}} + {{- $sources := slice -}} + {{- $author := partial "function-authors-data.html" . -}} + {{- $feeds := partial "function-generate-feeds.html" . -}} -{{- $inner := 1 -}} + {{- range $author.feeds.rss -}} + {{- $data := split . " " -}} + {{- $url := delimit (first 1 $data) "" -}} + {{- $sources = $sources | append (string $url) -}} + {{- end -}} -{{- if eq (len $sources) 1 -}} - {{- $inner = 3 -}} -{{- end -}} + {{- $inner := 1 -}} -{{- range $source := (first 3 $sources) -}} - {{- range $distinct := first $inner (where $feeds "FeedSourceLink" "eq" $source) -}} - {{- $items = $items | append $distinct -}} + {{- if eq (len $sources) 1 -}} + {{- $inner = 3 -}} {{- end -}} -{{- end -}} -{{- range (sort $items "FeedDateTime" "desc") -}} + {{- range $source := (first 3 $sources) -}} + {{- range $distinct := first $inner (where $feeds "FeedSourceLink" "eq" $source) -}} + {{- $items = $items | append $distinct -}} + {{- end -}} + {{- end -}} - <web-ring-item> - <header> + {{- range (sort $items "FeedDateTime" "desc") -}} + <web-ring-item> + <header> + <a + data-hover + title="{{ .FeedLink }}" + href="{{ .FeedLink }}"> + {{ or .FeedTitle (truncate 50 "..." (or .FeedContentShort .FeedDescriptionShort)) }} + </a> + </header> + <time + title="{{ .FeedDateTitle }}" + datetime="{{ .FeedDateTime }}"> + {{ .FeedDate }} + </time> + <p> + {{ "--" | markdownify }} + {{ if gt (len .FeedDescriptionShort) (len .FeedContentShort) -}} + {{ or .FeedDescriptionShort .FeedTitle }} + {{- else -}} + {{ or .FeedContentShort .FeedTitle }} + {{- end }} + — + </p> <a data-hover - title="{{ .FeedLink }}" - href="{{ .FeedLink }}"> - {{ or .FeedTitle (truncate 50 "..." (or .FeedContentShort .FeedDescriptionShort)) }} + title="{{ .FeedSourceDescription }}" + href="{{ or .FeedSourceHome .FeedSourceLink }}"> + {{ .FeedSourceTitle }} </a> - </header> - <time - title="{{ .FeedDateTitle }}" - datetime="{{ .FeedDateTime }}"> - {{ .FeedDate }} - </time> - <p> - {{ "--" | markdownify }} - {{ if gt (len .FeedDescriptionShort) (len .FeedContentShort) -}} - {{ or .FeedDescriptionShort .FeedTitle }} - {{- else -}} - {{ or .FeedContentShort .FeedTitle }} - {{- end }} - — - </p> - <a - data-hover - title="{{ .FeedSourceDescription }}" - href="{{ or .FeedSourceHome .FeedSourceLink }}"> - {{ .FeedSourceTitle }} - </a> - </web-ring-item> - + </web-ring-item> + {{- end -}} {{- end -}} diff --git a/themes/default/layouts/partials/generate-authors.html b/themes/default/layouts/partials/generate-authors.html index 61cc5a6..a0fd825 100644 --- a/themes/default/layouts/partials/generate-authors.html +++ b/themes/default/layouts/partials/generate-authors.html @@ -1,13 +1,13 @@ -{{- range .Site.Author.list -}} +{{- range $author := .Site.Author.list -}} - {{- if not (fileExists (print "data/" . ".yaml")) -}} + {{- if not (fileExists (print "data/" $author ".yaml")) -}} {{- $configuration := resources.Get "templates/author.yaml" -}} {{- $configuration := resources.ExecuteAsTemplate - (print "/data/generates/authors/" . ".yaml") + (print "/data/generates/authors/" $author ".yaml") (dict - "Name" (title .) - "User" . + "Name" (title $author) + "User" $author ) $configuration -}} @@ -18,9 +18,9 @@ {{- $markdown := resources.Get "templates/markdown-frontmatter.yaml" -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/" "_index.md") + (print "/data/generates/content/" $author "/" "_index.md") (dict - "author" . + "author" $author "layout" "section" ) $markdown @@ -28,9 +28,9 @@ {{- $writeToFile := $template.Permalink -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/feeds/" "_index.md") + (print "/data/generates/content/" $author "/feeds/" "_index.md") (dict - "author" . + "author" $author "layout" "section.feeds" ) $markdown @@ -38,9 +38,9 @@ {{- $writeToFile := $template.Permalink -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/media/" "_index.md") + (print "/data/generates/content/" $author "/media/" "_index.md") (dict - "author" . + "author" $author "layout" "section.media" ) $markdown @@ -48,9 +48,9 @@ {{- $writeToFile := $template.Permalink -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/likes/" "_index.md") + (print "/data/generates/content/" $author "/likes/" "_index.md") (dict - "author" . + "author" $author "layout" "section.likes" ) $markdown @@ -58,9 +58,9 @@ {{- $writeToFile := $template.Permalink -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/drafts/" "_index.md") + (print "/data/generates/content/" $author "/drafts/" "_index.md") (dict - "author" . + "author" $author "layout" "section.drafts" ) $markdown |