feat: make taxonomy URLs singular

- make taxonomy URLs singular, consistent with other Academic pages (workaround Hugo attempting to publish taxonomy URLs with plural names). This requires the breaking change below.
- Fix extra space/lines appearing in the author cards underneath page content as reported at https://spectrum.chat/academic/help/publication-widget-adds-additional-lines-at-bottom-of-the-page~315f77d8-7cc8-44a9-a431-5b64b7556c53

BREAKING CHANGE:
Rename `name` to `title` in author profiles within `author/` folder.
This commit is contained in:
George Cushen committed 2020-04-15 01:17:56 +01:00
1 parent f075bc2d74
commit 601620c7a6
11 files changed
+42 -35

No files matched your search

+7
View File
@@ -37,6 +37,13 @@ enableEmoji = true
footnotereturnlinkcontents = "<sup>^</sup>" footnotereturnlinkcontents = "<sup>^</sup>"
ignoreFiles = ["\\.ipynb$", ".ipynb_checkpoints$", "\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$"] ignoreFiles = ["\\.ipynb$", ".ipynb_checkpoints$", "\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$"]
# Workaround Hugo publishing taxonomy URLs as plurals - consistently use singular across Academic.
[permalinks]
authors = "/author/:slug/"
tags = "/tag/:slug/"
categories = "/category/:slug/"
publication_types = "/publication-type/:slug/"
[outputs] [outputs]
home = [ "HTML", "RSS", "JSON", "WebAppManifest" ] home = [ "HTML", "RSS", "JSON", "WebAppManifest" ]
section = [ "HTML", "RSS" ] section = [ "HTML", "RSS" ]
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
# Display name # Display name
name: Nelson Bighetti title: Nelson Bighetti
# Username (this should match the folder name) # Username (this should match the folder name)
authors: authors:
+1 -1
View File
@@ -12,7 +12,7 @@
<ul> <ul>
{{ $paginator := .Paginate .Data.Pages }} {{ $paginator := .Paginate .Data.Pages }}
{{ range $k, $v := $paginator.Pages }} {{ range $k, $v := $paginator.Pages }}
{{ $name := $v.Params.name | default ($v.Title|plainify) }} {{ $name := $v.Title }}
<li><a href="{{$v.Permalink}}">{{$name}}</a></li> <li><a href="{{$v.Permalink}}">{{$name}}</a></li>
{{ end }} {{ end }}
</ul> </ul>
+2 -4
View File
@@ -4,7 +4,7 @@
{{- /* Add the index page of docs separately since it's not in RegularPages above. */ -}} {{- /* Add the index page of docs separately since it's not in RegularPages above. */ -}}
{{- $pages := $pages | union (where (where site.Pages "Kind" "section") "Type" "docs") -}} {{- $pages := $pages | union (where (where site.Pages "Kind" "section") "Type" "docs") -}}
{{- /* Add author pages to index so their bios can be searched. Hide empty `/authors/` node. */ -}} {{- /* Add author pages to index so their bios can be searched. Hide empty `/authors/` node. */ -}}
{{- $pages := $pages | union (where (where site.Pages "Section" "authors") "Params.name" "!=" nil) -}} {{- $pages := $pages | union (where (where site.Pages "Section" "authors") "Params.superuser" "!=" nil) -}}
{{- range $pages -}} {{- range $pages -}}
{{- /* Do not index drafts or private pages. */ -}} {{- /* Do not index drafts or private pages. */ -}}
@@ -27,7 +27,6 @@
{{/* Correct the title and URL for author profile pages. */}} {{/* Correct the title and URL for author profile pages. */}}
{{- if eq .Section "authors" -}} {{- if eq .Section "authors" -}}
{{- $title = .Params.name -}}
{{- $username := path.Base (path.Split .Path).Dir -}} {{- $username := path.Base (path.Split .Path).Dir -}}
{{- with site.GetPage (printf "/authors/%s" $username) -}} {{- with site.GetPage (printf "/authors/%s" $username) -}}
{{- $permalink = .Permalink -}} {{- $permalink = .Permalink -}}
@@ -43,8 +42,7 @@
{{- $person_page_path := (printf "/authors/%s" (urlize $v)) -}} {{- $person_page_path := (printf "/authors/%s" (urlize $v)) -}}
{{- $person_page := site.GetPage $person_page_path -}} {{- $person_page := site.GetPage $person_page_path -}}
{{- if and $person_page $person_page.File -}} {{- if and $person_page $person_page.File -}}
{{- $person := $person_page.Params -}} {{- $authors = $authors | append $person_page.Title -}}
{{- $authors = $authors | append $person.name -}}
{{- else -}} {{- else -}}
{{- $authors = $authors | append ($v | plainify) -}} {{- $authors = $authors | append ($v | plainify) -}}
{{- end -}} {{- end -}}
@@ -18,7 +18,7 @@
{{ $taxonomy := "authors" }} {{ $taxonomy := "authors" }}
{{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_username) }} {{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_username) }}
{{ with $profile_page }} {{ with $profile_page }}
{{ $author = .Params.name | default .Title }} {{ $author = .Title }}
{{ else }} {{ else }}
{{ $author = $author | default $publisher }} {{ $author = $author | default $publisher }}
{{ end }} {{ end }}
+21 -19
View File
@@ -4,26 +4,28 @@
{{ $taxonomy := "authors" }} {{ $taxonomy := "authors" }}
{{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_urlized) }} {{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_urlized) }}
{{ with $profile_page }} {{ with $profile_page }}
{{/* If it's a personal site and primary page author is superuser, link to the homepage rather than their profile page. */}} {{ if isset .Params "superuser" }}{{/* Check an author profile exists. */}}
{{ $profile_url := .RelPermalink }} {{/* If it's a personal site and primary page author is superuser, link to the homepage rather than their profile page. */}}
{{ if and (eq $site_type "Person") (eq .Params.superuser true) }} {{ $profile_url := .RelPermalink }}
{{ $profile_url = site.BaseURL }} {{ if and (eq $site_type "Person") (eq .Params.superuser true) }}
{{ end }} {{ $profile_url = site.BaseURL }}
{{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
{{ $avatar_shape := site.Params.avatar.shape | default "circle" }}
<div class="media author-card content-widget-hr">
{{ if and site.Params.avatar.gravatar .Params.email }}
<img class="avatar mr-3 {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" alt="{{.Params.name}}">
{{ else if $avatar }}
{{ $avatar_image := $avatar.Fill "270x270 Center" }}
<img class="avatar mr-3 {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $avatar_image.RelPermalink }}" alt="{{.Params.name}}">
{{ end }} {{ end }}
{{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
{{ $avatar_shape := site.Params.avatar.shape | default "circle" }}
<div class="media author-card content-widget-hr">
{{ if and site.Params.avatar.gravatar .Params.email }}
<img class="avatar mr-3 {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" alt="{{.Title}}">
{{ else if $avatar }}
{{ $avatar_image := $avatar.Fill "270x270 Center" }}
<img class="avatar mr-3 {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $avatar_image.RelPermalink }}" alt="{{.Title}}">
{{ end }}
<div class="media-body"> <div class="media-body">
<h5 class="card-title"><a href="{{$profile_url}}">{{.Params.name}}</a></h5> <h5 class="card-title"><a href="{{$profile_url}}">{{.Title}}</a></h5>
{{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</h6>{{end}} {{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</h6>{{end}}
{{ with .Params.bio }}<p class="card-text">{{. | markdownify | emojify}}</p>{{end}} {{ with .Params.bio }}<p class="card-text">{{. | markdownify | emojify}}</p>{{end}}
{{ partial "social_links" . }} {{ partial "social_links" . }}
</div>
</div> </div>
</div> {{end}}
{{end}}{{/* Profile page block */}} {{end}}{{/* Profile page block */}}
+1 -1
View File
@@ -5,7 +5,7 @@
{{ $link_authors := site.Params.link_authors | default true }} {{ $link_authors := site.Params.link_authors | default true }}
{{ range $index, $value := . }} {{ range $index, $value := . }}
{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy (. | urlize)) -}} {{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy (. | urlize)) -}}
{{- $name := $profile_page.Params.name | default ($value|markdownify) -}} {{- $name := $profile_page.Title | default ($value|markdownify) -}}
{{- if gt $index 0 }}, {{ end -}} {{- if gt $index 0 }}, {{ end -}}
<span> <span>
{{- if and $profile_page $link_authors -}} {{- if and $profile_page $link_authors -}}
+3 -3
View File
@@ -12,7 +12,7 @@
{{ $superuser_username := "" }} {{ $superuser_username := "" }}
{{ $superuser_role := "" }} {{ $superuser_role := "" }}
{{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }} {{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }}
{{ $superuser_name = .Params.name }} {{ $superuser_name = .Title }}
{{ $superuser_username = path.Base (path.Split .Path).Dir }} {{ $superuser_username = path.Base (path.Split .Path).Dir }}
{{ $superuser_role = .Params.role }} {{ $superuser_role = .Params.role }}
{{ end }} {{ end }}
@@ -182,7 +182,7 @@
{{ end }} {{ end }}
<meta property="og:site_name" content="{{ site.Title }}"> <meta property="og:site_name" content="{{ site.Title }}">
<meta property="og:url" content="{{ .Permalink }}"> <meta property="og:url" content="{{ .Permalink }}">
<meta property="og:title" content="{{ if not .IsHome }}{{ .Params.name | default .Title }} | {{ end }}{{ site.Title }}"> <meta property="og:title" content="{{ if not .IsHome }}{{ .Title }} | {{ end }}{{ site.Title }}">
<meta property="og:description" content="{{ $desc }}"> <meta property="og:description" content="{{ $desc }}">
{{- with $og_image -}} {{- with $og_image -}}
<meta property="og:image" content="{{.}}"> <meta property="og:image" content="{{.}}">
@@ -206,6 +206,6 @@
{{ partial "custom_head" . }} {{ partial "custom_head" . }}
<title>{{ if not .IsHome }}{{ .Params.name | default .Title }} | {{ end }}{{ site.Title }}</title> <title>{{ if not .IsHome }}{{ .Title }} | {{ end }}{{ site.Title }}</title>
</head> </head>
+3 -3
View File
@@ -23,14 +23,14 @@
<div id="profile"> <div id="profile">
{{ if site.Params.avatar.gravatar }} {{ if site.Params.avatar.gravatar }}
<img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="https://s.gravatar.com/avatar/{{ md5 $person.email }}?s=270')" alt="{{$person.name}}"> <img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="https://s.gravatar.com/avatar/{{ md5 $person.email }}?s=270')" alt="{{$person_page.Title}}">
{{ else if $avatar }} {{ else if $avatar }}
{{ $avatar_image := $avatar.Fill "270x270 Center" }} {{ $avatar_image := $avatar.Fill "270x270 Center" }}
<img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $avatar_image.RelPermalink }}" alt="{{$person.name}}"> <img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $avatar_image.RelPermalink }}" alt="{{$person_page.Title}}">
{{ end }} {{ end }}
<div class="portrait-title"> <div class="portrait-title">
<h2>{{ $person.name }}</h2> <h2>{{ $person_page.Title }}</h2>
{{ with $person.role }}<h3>{{ . | markdownify | emojify }}</h3>{{ end }} {{ with $person.role }}<h3>{{ . | markdownify | emojify }}</h3>{{ end }}
{{ range $person.organizations }} {{ range $person.organizations }}
+1 -1
View File
@@ -50,7 +50,7 @@
{{ end }} {{ end }}
<div class="portrait-title"> <div class="portrait-title">
<h2>{{with $link}}<a href="{{.}}">{{end}}{{ .Params.name }}{{if $link}}</a>{{end}}</h2> <h2>{{with $link}}<a href="{{.}}">{{end}}{{ .Title }}{{if $link}}</a>{{end}}</h2>
{{ with .Params.role }}<h3>{{ . | markdownify | emojify }}</h3>{{ end }} {{ with .Params.role }}<h3>{{ . | markdownify | emojify }}</h3>{{ end }}
{{ if $show_social }}{{ partial "social_links" . }}{{ end }} {{ if $show_social }}{{ partial "social_links" . }}{{ end }}
{{ if and $show_interests .Params.interests }}<p class="people-interests">{{ delimit .Params.interests ", " | markdownify | emojify }}</p>{{ end }} {{ if and $show_interests .Params.interests }}<p class="people-interests">{{ delimit .Params.interests ", " | markdownify | emojify }}</p>{{ end }}
+1 -1
View File
@@ -2,7 +2,7 @@
{{- $username_url := $username | urlize -}} {{- $username_url := $username | urlize -}}
{{- $taxonomy := "authors" -}} {{- $taxonomy := "authors" -}}
{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $username_url) -}} {{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $username_url) -}}
{{- $name := $profile_page.Params.name | default ($username|markdownify) -}} {{- $name := $profile_page.Title | default ($username|markdownify) -}}
{{- with $profile_page -}} {{- with $profile_page -}}
<a href="{{$profile_page.RelPermalink}}">{{$name}}</a> <a href="{{$profile_page.RelPermalink}}">{{$name}}</a>
{{- else -}} {{- else -}}