Skip to content

Commit

Permalink
added numbering to publications
Browse files Browse the repository at this point in the history
simplified authorlist.html (with the help of chatGPT!)
  • Loading branch information
kri-iqc committed Aug 12, 2024
1 parent 2217cd3 commit 909a548
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 94 deletions.
94 changes: 22 additions & 72 deletions layouts/partials/authorList.html
Original file line number Diff line number Diff line change
@@ -1,81 +1,31 @@
{{ $members := where .Site.Pages "Section" "members"}}
{{ $members := where .Site.Pages "Section" "members" }}
{{ $pun_count := 0 }}
{{ with .Params.authors }}
{{ $pun_count = len . }}
{{ end }}

{{ if eq $pun_count 2 }}

{{ range .Params.authors }}
{{ if (eq (len .) 2) }}
{{ $author := . }}
{{ if .Params.authors }}
{{ $pun_count = len .Params.authors }}

{{ range $index, $author := .Params.authors }}
{{ if (eq (len $author) 2) }}
{{ $found := false }}
{{ $separator := "," }}
{{ if eq $index (sub $pun_count 1) }}{{ $separator = "" }}{{ end }}
{{ if eq $pun_count 1 }}{{ $separator = "." }}{{ end }}
{{ range $members }}
{{ if in .Params.tags (index $author 1)}}
{{ if eq $pun_count 1 }}

<a href="{{ .Permalink }}" class="link black bg-animate dim b">
{{ printf "%s" (index $author 0)}}
</a>
{{ else }}
<a href="{{ .Permalink }}" class="link black bg-animate dim b">
{{ printf "%s" (index $author 0)}}
</a>
{{ end }}
{{ end }}
{{ if in .Params.tags (index $author 1) }}
{{ $found = true }}
<a href="{{ .Permalink }}" class="link black bg-animate dim b">
{{ printf "%s%s" (index $author 0) $separator }}
</a>
{{ end }}
{{ end }}
{{ else }}
{{ if eq $pun_count 1 }}
{{ printf "%s." (index . 0) }}
{{ else }}
{{ printf "%sl" (index . 0) }}
{{ end }}
{{ end }}
{{ $pun_count = sub $pun_count 1 }}
{{ end }}

{{ else if eq $pun_count 1 }}

{{ range .Params.authors }}
{{ if (eq (len .) 2) }}
{{ $author := . }}
{{ range $members }}
{{ if in .Params.tags (index $author 1)}}
<a href="{{ .Permalink }}" class="link black bg-animate dim b">
{{ printf "%s" (index $author 0)}}
</a>
{{ end }}
{{ if not $found }}
{{ printf "%s%s" (index $author 0) $separator }}
{{ end }}
{{ else }}
{{ printf "%s." (index . 0) }}
{{ end }}
{{ $pun_count = sub $pun_count 1 }}
{{ end }}

{{ else }}

{{ range .Params.authors }}
{{ if (eq (len .) 2) }}
{{ $author := . }}
{{ range $members }}
{{ if in .Params.tags (index $author 1)}}
{{ if eq $pun_count 1 }}
<a href="{{ .Permalink }}" class="link black bg-animate dim b">
{{ printf "%s." (index $author 0)}}
</a>
{{ else }}
<a href="{{ .Permalink }}" class="link black bg-animate dim b">
{{ printf "%s," (index $author 0)}}
</a>
{{ end }}
{{ end }}
{{ end }}
{{ else }}
{{ if eq $pun_count 1 }}
{{ printf "%s." (index . 0) }}
{{ else }}
{{ printf "%s," (index . 0) }}
{{ end }}
{{ $separator := "," }}
{{ if eq $index (sub $pun_count 1) }}{{ $separator = "" }}{{ end }}
{{ if eq $pun_count 1 }}{{ $separator = "." }}{{ end }}
{{ printf "%s%s" (index $author 0) $separator }}
{{ end }}
{{ $pun_count = sub $pun_count 1 }}
{{ end }}
{{ end }}
44 changes: 23 additions & 21 deletions layouts/partials/pub-list-2.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
{{ $section := . }}
{{ $section_count := len $section }}
{{ $section_name := "Publications" }}
<div class="relative w-100 mb2">
<section class="w-100 mw8">
{{ range $section }}
<div class="bb b--black-10 relative w-100 mb2 nested-copy-line-height" style="background-color:rgb(252,251,248)">
<div class="ph3 pv2 gray overflow-hidden">
<h1 class="f4 black mb0">
[{{ substr .Date 0 4 }}]
<a href="{{ .Permalink }}" class="link black dim">
{{ .Title }}
</a>
</h1>
<div class="mb0 near-black f5">
{{ partial "authorList.html" . }}
<div class="relative w-100 mb2">
<section class="w-100 mw8">
{{ $counter := $section_count }} <!-- Start the counter from the total number of publications -->
{{ range sort $section "Date" "desc" }} <!-- Sort by date in descending order -->
<div class="bb b--black-10 relative w-100 mb2 nested-copy-line-height" style="background-color:rgb(252,251,248)">
<div class="ph3 pv2 gray overflow-hidden">
<h1 class="f4 black mb0">
{{ $counter }}. [{{ substr .Date 0 4 }}]
<a href="{{ .Permalink }}" class="link black dim">
{{ .Title }}
</a>
</h1>
<div class="mb0 near-black f5">
{{ partial "authorList.html" . }}
<br>
{{ partial "journal-link-bar.html" . }}
</div>
<div class='near-black'>
<a href="{{.Permalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt1 ph2 pv1" style="background-color:rgb(230,225,230)">Read More</a>
</div>
{{ partial "journal-link-bar.html" . }}
</div>
<div class='near-black'>
<a href="{{.Permalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt1 ph2 pv1" style="background-color:rgb(230,225,230)">Read More</a>
</div>
</div>
{{ end }}
</section>
</div>
</div>
{{ $counter = sub $counter 1 }} <!-- Decrement the counter for each publication -->
{{ end }}
</section>
</div>
1 change: 1 addition & 0 deletions layouts/publications/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ <h1>{{ index $titleCards . }}</h1>
</section>
</article>
{{ end }}

2 changes: 1 addition & 1 deletion layouts/shortcodes/publist.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
{{ end }}
{{ end }}
{{ if ge (len $list) 1 }}
{{ partial "pub-list-2.html" $list }}
{{ partial "pub-list-2.html" $list}}
{{ end }}

0 comments on commit 909a548

Please sign in to comment.