Skip to content

Commit

Permalink
Merge pull request #3 from LordMathis/feature/post-metadata
Browse files Browse the repository at this point in the history
Feature/post metadata
  • Loading branch information
lordmathis authored May 3, 2023
2 parents 9031afb + 14e4655 commit 549693f
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Nightfall is a minimal dark theme for Hugo

![Hugo Theme Nightfall](https://raw.githubusercontent.com/LordMathis/hugo-theme-nightfall/main/images/screenshot.png)
![Hugo Theme Nightfall Posts](https://raw.githubusercontent.com/LordMathis/hugo-theme-nightfall/main/images/screenshot_2.png)
![Hugo Theme Nightfall Single](https://raw.githubusercontent.com/LordMathis/hugo-theme-nightfall/main/images/screenshot_3.png)

## Get the theme

Expand Down Expand Up @@ -70,7 +71,6 @@ To add a menu item add `[[menu.header]]` item to `config.toml`. For example:

To use icons for social links, you also need to add the link to icon font to custom-head.html


## Custom Head

To use custom icons, css, js or other resources create `layouts/partials/custom-head.html` and add your links there.
28 changes: 28 additions & 0 deletions assets/sass/pages/_single.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,32 @@

.postWrapper {
text-align: left;
}

.postMetadata {
font-family: $fontCode;
display: block;
background: $backgroundDarker;
padding: 10px;
}

dt, dd {
line-height: 1.5;
}

dl {
display: grid;
grid-template-columns: max-content auto;
}

dt {
grid-column-start: 1;
}

dd {
grid-column-start: 2;
}

dt::after {
content: ":";
}
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ author = "Hugo Nightfall"
user = "hello"
hostname = "gohugo.io"

readingTime = true # Show reading time on post page
published = true # Show published data on post page

[[params.social]]
key = 0
name = "github"
Expand Down
Binary file added images/screenshot_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ <h1>{{ .Title }}</h1>
<div class="postListItem" role="listitem">
<div class="postHeader">
<span class="postTitle">{{ .Title }}</span>
<span class="postDate">{{ .Date.Format "January 2, 2006" }}</span>
{{ $formattedDate := .Date.Format "2006-01-02" }}
<time class="postDate" datetime="{{ $formattedDate }}">{{ .Date.Format "January 2, 2006" }}</time>
</div>
<div class="postExcerpt">
<p>{{ .Summary }}</p>
Expand Down
22 changes: 22 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@
{{ define "main" }}
<div class="postWrapper">
<h1>{{ .Title }}</h1>
<section class="postMetadata">
<dl>
{{ with .GetTerms "tags" }}
{{ partial "taxonomy/tags.html" . }}
{{ end }}
{{ with .GetTerms "authors" }}
{{ partial "taxonomy/authors.html" . }}
{{ end }}
{{ with .GetTerms "categories" }}
{{ partial "taxonomy/categories.html" . }}
{{ end }}
{{ if .Site.Params.published | default true }}
<dt>published</dt>
{{ $formattedDate := .Date.Format "2006-01-02" }}
<dd><time datetime="{{ $formattedDate }}">{{ .Date.Format "January 2, 2006" }}</time></dd>
{{ end }}
{{ if .Site.Params.readingTime | default true }}
<dt>reading time</dt>
<dd>{{ math.Round (div (countwords .Content) 220.0) }} minutes</dd>
{{ end }}
</dl>
</section>
<div>
{{ .Content }}
</div>
Expand Down
8 changes: 8 additions & 0 deletions layouts/partials/taxonomy/authors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- [html-validate-disable element-required-ancestor] -->
<dt>authors</dt>
<dd>
{{- range $index, $el := . -}}
<span></span>
<a href="{{ .RelPermalink }}">{{- .LinkTitle -}}</a>
{{- end -}}
</dd>
8 changes: 8 additions & 0 deletions layouts/partials/taxonomy/categories.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- [html-validate-disable element-required-ancestor] -->
<dt>categories</dt>
<dd>
{{- range $index, $el := . -}}
<span></span>
<a href="{{ .RelPermalink }}">{{- .LinkTitle -}}</a>
{{- end -}}
</dd>
8 changes: 8 additions & 0 deletions layouts/partials/taxonomy/tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- [html-validate-disable element-required-ancestor] -->
<dt>tags</dt>
<dd>
{{- range $index, $el := . -}}
<span></span>
<a href="{{ .RelPermalink }}">#{{ .LinkTitle }}</a>
{{- end -}}
</dd>

0 comments on commit 549693f

Please sign in to comment.