Browse Source

partials: Fix case where `.Permalink` may be called on nil

See #534 and #532
George Cushen 7 years ago
parent
commit
9842f517dd
2 changed files with 14 additions and 6 deletions
  1. 7 3
      layouts/partials/publication_links.html
  2. 7 3
      layouts/partials/talk_links.html

+ 7 - 3
layouts/partials/publication_links.html

@@ -31,9 +31,13 @@
 {{ end }}
 {{ if $.Params.projects }}
 {{ range $.Params.projects }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ ($.Site.GetPage "page" "project" .).Permalink }}">
-  {{ i18n "btn_project" }}
-</a>
+  {{ with ($.Site.GetPage "page" "project" .) }}
+  <a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ .Permalink }}">
+    {{ i18n "btn_project" }}
+  </a>
+  {{ else }}
+    {{ errorf "Please check that the `projects` parameter in the front matter of content in `content/publication/` refers to an existing filename (without .md extension) of a published project." }}
+  {{ end }}
 {{ end }}
 {{ else }}
 {{ with $.Params.url_project }}

+ 7 - 3
layouts/partials/talk_links.html

@@ -22,9 +22,13 @@
 </a>
 {{ end }}
 {{ range $.Params.projects }}
-<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ ($.Site.GetPage "page" "project" .).Permalink }}">
-  {{ i18n "btn_project" }}
-</a>
+  {{ with ($.Site.GetPage "page" "project" .) }}
+  <a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ .Permalink }}">
+    {{ i18n "btn_project" }}
+  </a>
+  {{ else }}
+    {{ errorf "Please check that the `projects` parameter in the front matter of content in `content/talk/` refers to an existing filename (without .md extension) of a published project." }}
+  {{ end }}
 {{ end }}
 {{ range $.Params.url_custom }}
 <a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ .url | absURL }}">