From c88f90bd5d706c406f4a8df2b6c8158aae0beb34 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Tue, 7 May 2019 22:36:24 +0100 Subject: [PATCH] fix: build fails on Windows: "Error: Could not find author page at..." Fix #1068 Fix #1064 --- layouts/index.json | 10 +++++----- layouts/partials/header.html | 2 +- layouts/partials/page_links_div.html | 6 +----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/layouts/index.json b/layouts/index.json index 4854ae48..4e9f95d7 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -26,10 +26,10 @@ {{- $permalink := .Permalink -}} {{/* Correct the title and URL for author profile pages. */}} - {{- if eq .Section "author" -}} + {{- if eq .Section "authors" -}} {{- $title = .Params.name -}} - {{- $dir := path.Base (path.Split .Path).Dir -}} - {{- with site.GetPage (printf "/authors/%s" (path.Base (path.Split .Path).Dir)) -}} + {{- $username := path.Base (path.Split .Path).Dir -}} + {{- with site.GetPage (printf "/authors/%s" $username) -}} {{- $permalink = .Permalink -}} {{- $rel_permalink = .RelPermalink -}} {{- end -}} @@ -40,9 +40,9 @@ {{- if gt $authorLen 0 -}} {{- $authors = slice -}} {{- range $k, $v := .Params.authors -}} - {{- $person_page_path := (printf "/author/%s" (urlize $v)) -}} + {{- $person_page_path := (printf "/authors/%s" (urlize $v)) -}} {{- $person_page := site.GetPage $person_page_path -}} - {{- if $person_page -}} + {{- if and $person_page $person_page.File -}} {{- $person := $person_page.Params -}} {{- $authors = $authors | append $person.name -}} {{- else -}} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index a582ec50..a001339b 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -15,7 +15,7 @@ {{ $superuser_role := "" }} {{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }} {{ $superuser_name = .Params.name }} - {{ $superuser_username = delimit (last 1 (split (substr .File.Dir 0 -1) "/")) "" }} + {{ $superuser_username = path.Base (path.Split .Path).Dir }} {{ $superuser_role = .Params.role }} {{ end }} {{ $scr.Set "superuser_username" $superuser_username }}{{/* For access from page_author.html. */}} diff --git a/layouts/partials/page_links_div.html b/layouts/partials/page_links_div.html index 108bf458..57f63255 100644 --- a/layouts/partials/page_links_div.html +++ b/layouts/partials/page_links_div.html @@ -4,11 +4,7 @@ {{ $page := . }} {{ $pdf_link := false }} {{ $cite_link := false }} - -{{ $slug := "" }} -{{ if eq $page.File.TranslationBaseName "index" }}{{/* Check if using dir-based page bundles. */}} - {{ $slug = delimit (last 1 (split (substr $page.File.Dir 0 -1) "/")) "" }} -{{ end }} +{{ $slug := $page.File.ContentBaseName }} {{ $resource := $page.Resources.GetMatch (printf "%s.pdf" $slug) }} {{ with $resource }} {{ $pdf_link = true }}