Improve 404 error page (Close #332)

* Internationalize the page (string translation)
  * Add 3 new language variables: page_not_found, 404_recommendations,
    projects
* Show recent talks and projects
* For each content type, show most recent 5 items
* Only show content headings if content exists for each type of content
This commit is contained in:
George Cushen 2017-10-19 22:13:18 +01:00
commit d8577538ca
2 changed files with 43 additions and 6 deletions

View file

@ -127,3 +127,14 @@
- id: talks
translation: Talks
- id: projects
translation: Projects
# Error 404
- id: page_not_found
translation: Page not found
- id: 404_recommendations
translation: Perhaps you were looking for one of these?

View file

@ -2,22 +2,48 @@
{{ partial "navbar.html" . }}
<div class="container">
<h1>Page not found</h1>
<p>Maybe you were looking for one of these?</p>
<h1>{{ i18n "page_not_found" }}</h1>
<p>{{ i18n "404_recommendations" }}</p>
<h2>Recent Posts</h2>
{{ range last 20 (where .Data.Pages "Section" "=" "post") }}
{{ $posts_len := len (where .Site.RegularPages "Section" "post") }}
{{ if gt $posts_len 0 }}
<h2>{{ i18n "posts" }}</h2>
{{ range last 5 (where .Site.RegularPages "Section" "post") }}
<ul>
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
</ul>
{{ end }}
{{ end }}
<h2>Recent Publications</h2>
{{ range last 20 (where .Data.Pages "Section" "=" "publication") }}
{{ $pubs_len := len (where .Site.RegularPages "Section" "publication") }}
{{ if gt $pubs_len 0 }}
<h2>{{ i18n "publications" }}</h2>
{{ range last 5 (where .Site.RegularPages "Section" "publication") }}
<ul>
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
</ul>
{{ end }}
{{ end }}
{{ $talks_len := len (where .Site.RegularPages "Section" "talk") }}
{{ if gt $talks_len 0 }}
<h2>{{ i18n "talks" }}</h2>
{{ range last 5 (where .Site.RegularPages "Section" "talk") }}
<ul>
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
</ul>
{{ end }}
{{ end }}
{{ $projects_len := len (where .Site.RegularPages "Section" "project") }}
{{ if gt $projects_len 0 }}
<h2>{{ i18n "projects" }}</h2>
{{ range last 5 (where .Site.RegularPages "Section" "project") }}
<ul>
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
</ul>
{{ end }}
{{ end }}
</div>
{{ partial "footer_container.html" . }}