mirror of
https://github.com/foo-dogsquared/hugo-theme-more-contentful.git
synced 2025-04-19 00:19:14 +00:00

The Hugo theme will also generate a counterpart system theme if there's only one system theme given. Though, it isn't perfect so the release will not happen for a while. I'll look into generating a color palette with HSLuv to see if it can be improved.
72 lines
2.6 KiB
HTML
72 lines
2.6 KiB
HTML
{{- /*
|
|
Here's where all of the inline partials are defined.
|
|
If the partial is short enough, it should be put here.
|
|
*/ -}}
|
|
|
|
{{- /*
|
|
This is a partial that creates an icon from the icon templates and links them from the created file.
|
|
Why not embed the text into the resulting document, you ask?
|
|
I just want to save a few kilobytes of the total site weight. :)
|
|
|
|
It accepts a dictionary with the specified keys:
|
|
|
|
- id - The name of the resource in a specific set.
|
|
- output - The output location of the resource relative to the base URL.
|
|
It can accept a formatted string (e.g., "icons/brand/%s.svg") where 'id' will be used.
|
|
- template - The template file to be used.
|
|
It should be relative to the asset directory.
|
|
*/ -}}
|
|
{{- define "partials/components/icon.html" }}
|
|
{{- $icon := . }}
|
|
{{- $res := resources.ExecuteAsTemplate (printf $icon.output $icon.id) $icon.id (resources.Get $icon.template) }}
|
|
<svg class="icon">
|
|
<use href="{{ $res.Permalink }}#{{ $icon.id }}"></use>
|
|
</svg>
|
|
{{- end }}
|
|
|
|
|
|
{{- /*
|
|
A partial that aliases the Heroicon template from the icon partial.
|
|
It only needs a string of the ID from one of the icons.
|
|
*/ -}}
|
|
{{- define "partials/components/heroicon.html" }}
|
|
{{- partial "components/icon.html" (dict "id" . "output" "icons/generic/%s.svg" "template" "templates/heroicon.svg") }}
|
|
{{ end }}
|
|
|
|
|
|
{{- /*
|
|
The component where it will display the metadata of the post.
|
|
This is used on list templates but feel free to change that.
|
|
*/ -}}
|
|
{{- define "partials/components/post-meta.html" }}
|
|
<div class="list post__meta">
|
|
{{- if ne (.PublishDate.Format "2006") "0001" -}}
|
|
<time datetime="{{ .PublishDate }}">
|
|
{{ partial "components/heroicon.html" "calendar" }}
|
|
<span style="margin-left: 0.5em;">{{ .PublishDate.Format "2006-01-02" }}</span>
|
|
</time>
|
|
{{- end }}
|
|
|
|
{{- if and .GitInfo (ne (.PublishDate.Format "2006-01-02") (.Lastmod.Format "2006-01-02")) }}
|
|
<time datetime="{{ .Lastmod }}">
|
|
{{ partial "components/heroicon.html" "refresh" }}
|
|
<span style="margin-left: 0.5em;">{{ .Lastmod.Format "2006-01-02" }}</span>
|
|
</time>
|
|
{{- end }}
|
|
|
|
{{- /* The authors are appended with 'et al' if there's more than one author in the map. */ -}}
|
|
{{ with .Params.author }}
|
|
{{- $names := slice }}
|
|
{{- range . }}{{ $names = $names | append .name }}{{ end }}
|
|
{{- $author := index (first 1 $names) 0 }}
|
|
<span data-authors="{{ jsonify $names }}">
|
|
{{ partial "components/heroicon.html" "pencil" }}
|
|
<span style="margin-left: 0.5em;">
|
|
{{ $author }}{{ if ge (len .) 2 }}, et al.{{ end }}
|
|
</span>
|
|
</span>
|
|
{{ end }}
|
|
|
|
</div>
|
|
{{- end }}
|