Browse Source

fix: build fails on Windows: "Error: Could not find author page at..."

Fix #1068
Fix #1064
George Cushen 6 years ago
parent
commit
c88f90bd5d
3 changed files with 7 additions and 11 deletions
  1. 5 5
      layouts/index.json
  2. 1 1
      layouts/partials/header.html
  3. 1 5
      layouts/partials/page_links_div.html

+ 5 - 5
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 -}}

+ 1 - 1
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. */}}

+ 1 - 5
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 }}