Update the layouts

This commit is contained in:
foo-dogsquared 2020-05-13 01:41:43 +08:00
parent 4e81d9ed48
commit 21be4bd564
10 changed files with 51 additions and 18 deletions

View File

@ -10,9 +10,15 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
== [Unreleased] == [Unreleased]
=== Changed
* Fix relative links for multilingual mode.
== [1.1.1] - 2020-05-12
== [1.2.0] - 2020-05-12
=== Added === Added
@ -67,6 +73,7 @@ The page config has more priority and can override the site config.
=== Added === Added
* Create the base layout. * Create the base layout.
* Add the Asciidoctor content template. * Add the Asciidoctor content template.
* Create the template for RSS, Atom, and JSON web syndication feeds. * Create the template for RSS, Atom, and JSON web syndication feeds.

View File

@ -15,6 +15,15 @@ All it needs is the `title` field from your site config.
## Demo
There's a demo available at the `demo` branch with the live version at https://foo-dogsquared.github.io/hugo-theme-contentful/.
It features a multilingual site with the default settings.
## Feature list ## Feature list
The quickest way to describe Contentful in one go is a list. The quickest way to describe Contentful in one go is a list.
@ -169,7 +178,12 @@ It could be handy for guest posts and co-authored papers with others.
You can have web syndication formats like RSS and Atom by setting [custom output formats](https://gohugo.io/templates/output-formats) to your site configurations. You can have web syndication formats like RSS and Atom by setting [custom output formats](https://gohugo.io/templates/output-formats) to your site configurations.
The theme mainly supports output feeds for the homepage and site sections. The theme mainly supports output feeds for the homepage and site sections.
I should point out that the web feeds prints the whole and links. I should point out that the web feeds prints the whole content instead of summaries.
Also, they all rely on an icon to be placed in `icon.png`.
For more accurate control regarding the icon paths, you can copy the templates (at `theme/contentful/layouts/_default/list.{rss,atom,json}`) to your own layout folder.
I've conveniently placed some key phrases to easily find them.
Just search for the phrase `ICON, AHOY!` and the icon is usually below it then make your desired changes.
Here is an example configuration on enabling all of them. Here is an example configuration on enabling all of them.

View File

@ -28,7 +28,7 @@ other = "Translations"
# General # General
[and] [and]
other = "And" other = "and"
[back_to_home] [back_to_home]
other = "Back to home" other = "Back to home"

View File

@ -7,8 +7,12 @@
{{- printf "<link rel=%q type=%q href=%q/>" .Rel .MediaType .Permalink | safeHTML }} {{- printf "<link rel=%q type=%q href=%q/>" .Rel .MediaType .Permalink | safeHTML }}
{{- end }} {{- end }}
<rights>{{ with .Site.Copyright }}{{ . }}{{ else }}© {{ now.Year }} {{ with .Site.Author.name }}{{ . }}{{ end }}{{ end }}</rights> <rights>{{ with .Site.Copyright }}{{ . }}{{ else }}© {{ now.Year }} {{ with .Site.Author.name }}{{ . }}{{ end }}{{ end }}</rights>
<generator>Hugo -- gohugo.io</generator> <generator uri="https://gohugo.io/" version="{{ hugo.Version }}" type="text">Hugo</generator>
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated> <updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>
<id>{{ "" | absLangURL }}</id>
{{- /* ICON, AHOY! */ -}}
<icon>{{ "icon.png" | absURL }}</icon>
{{ with .Site.Author }} {{ with .Site.Author }}
<author> <author>
@ -16,15 +20,14 @@
{{ with .email }}<email>{{ . }}</email>{{ end }} {{ with .email }}<email>{{ . }}</email>{{ end }}
</author> </author>
{{ end }} {{ end }}
<id>{{ .Permalink }}</id>
{{- /* Generate each valid regular pages (with as an individual entry in the feed. */ -}} {{- /* Generate each valid regular pages (with as an individual entry in the feed. */ -}}
{{ $limit := cond (gt .Site.Params.feedLimit 0) .Site.Params.feedLimit 10 }} {{ $limit := cond (gt .Site.Params.feedLimit 0) .Site.Params.feedLimit 10 }}
{{ $pages := .Pages }} {{ $pages := .Pages }}
{{ if .IsHome }} {{ if .IsHome }}
{{ $pages = where $.Site.RegularPages "Type" "in" $.Site.Params.mainSections }} {{ $pages = where $.Site.RegularPages "Type" "in" $.Site.Params.mainSections }}
{{ end }} {{ end }}
{{ range first $limit (where $pages "Params.hidden" "!=" true) }} {{ range first $limit (where $pages "Params.hidden" "!=" true) }}
<entry> <entry>
<id>{{ .Permalink }}</id> <id>{{ .Permalink }}</id>
<title type="text">{{ .Title }}</title> <title type="text">{{ .Title }}</title>

View File

@ -1,11 +1,13 @@
{ {
"version": "https://jsonfeed.org/version/1", "version": "https://jsonfeed.org/version/1",
"title": "{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}", "title": "{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}",
"home_page_url": "{{ .Site.BaseURL }}", "home_page_url": "{{ "" | absLangURL }}",
"feed_url": "{{ with .OutputFormats.Get "json" }}{{ .Permalink }}{{ end }}", "feed_url": "{{ with .OutputFormats.Get "json" }}{{ .Permalink }}{{ end }}",
"description": "Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}", "description": "Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}",
"favicon": "{{ "assets/icon.png" | absURL }}", {{- /* ICON, AHOY! */ -}}
"icon": "{{ "assets/icon.png" | absURL }}", "favicon": "{{ "icon.png" | absURL }}",
"icon": "{{ "icon.png" | absURL }}",
{{- with .Site.Author }} {{- with .Site.Author }}
"author": { "author": {
"name": "{{ .name }}" "name": "{{ .name }}"

View File

@ -14,6 +14,8 @@ The template does miss out on certain things which I put it on a list for those
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description> <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator> <generator>Hugo -- gohugo.io</generator>
{{- /* ICON, AHOY! */ -}}
<image>{{ "icon.png" | absURL }}</image>
{{ with .Site.LanguageCode }} {{ with .Site.LanguageCode }}
<language>{{.}}</language> <language>{{.}}</language>

View File

@ -8,7 +8,7 @@
{{- with .Params.author }} {{- with .Params.author }}
{{- $names := slice }} {{- $names := slice }}
{{- range . }}{{ $names = $names | append .name }}{{ end }} {{- range . }}{{ $names = $names | append .name }}{{ end }}
<p class="author">{{ i18n "published_by" }}: {{ delimit $names ", " ", and " }}</p> <p class="author">{{ i18n "published_by" }}: {{ delimit $names ", " (printf ", %s " (i18n "and")) }}</p>
{{- end }} {{- end }}
<!-- Only show the creation date if the `date` field is valid. --> <!-- Only show the creation date if the `date` field is valid. -->

View File

@ -1,7 +1,7 @@
<hr> <hr>
<footer> <footer>
<!-- A convenient back to home. --> <!-- A convenient back to home. -->
<p><a href="{{ $.Site.BaseURL }}">{{ i18n "back_to_home" }}</a></p> <p><a href="{{ "" | absLangURL }}">{{ i18n "back_to_home" }}</a></p>
</footer> </footer>
<!-- Linking to other languages' homepage. --> <!-- Linking to other languages' homepage. -->

View File

@ -1,9 +1,9 @@
<nav aria-labelledby="primary-navigation"> <nav aria-labelledby="primary-navigation">
<a class="site__title" href="{{ $.Site.BaseURL }}">{{ $.Site.Title }}</a> <a class="site__title" href="{{ "" | absLangURL }}">{{ $.Site.Title }}</a>
<div class="site__links"> <div class="site__links">
| |
{{ range $.Site.Menus.main -}} {{ range $.Site.Menus.main -}}
<a href="{{ .URL | absURL }}">{{ .Name }}</a> | <a href="{{ .URL | absLangURL }}">{{ .Name }}</a> |
{{ end }} {{ end }}
</div> </div>
<button class="site__theme-btn" aria-label="theme-toggle" onclick="const theme = window.localStorage.getItem('theme') == 'dark' ? 'light' : 'dark'; window.localStorage.setItem('theme', theme); document.documentElement.dataset.theme = theme"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12-5.373-12-12-12-12 5.373-12 12zm2 0c0-5.514 4.486-10 10-10v20c-5.514 0-10-4.486-10-10z"></path></svg></button> <button class="site__theme-btn" aria-label="theme-toggle" onclick="const theme = window.localStorage.getItem('theme') == 'dark' ? 'light' : 'dark'; window.localStorage.setItem('theme', theme); document.documentElement.dataset.theme = theme"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12-5.373-12-12-12-12 5.373-12 12zm2 0c0-5.514 4.486-10 10-10v20c-5.514 0-10-4.486-10-10z"></path></svg></button>

View File

@ -76,11 +76,16 @@ dd, li, p, td {
line-height: 1.5; line-height: 1.5;
} }
dd, p { p {
margin-top: 1rem; margin-top: 1rem;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
dd{
margin-top: 0.5rem;
margin-bottom: 1.5rem;
}
kbd { kbd {
border: var(--border-style); border: var(--border-style);
font-size: 0.85rem; font-size: 0.85rem;