Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dataCobra/hugo-vitae.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordataCobra <datacobra@thinkbot.de>2021-07-11 20:26:51 +0300
committerdataCobra <datacobra@thinkbot.de>2021-07-11 20:26:51 +0300
commitd63a590b454bed876bcc204f27ab1e769b47907c (patch)
tree0b60f0f3a003093b55a0b04e32eb3866c8de017d
parent79c300822b3b42e001c25e533293c964e78cec9f (diff)
Add metadata (readingTime, wordCount, author) #61
This commits ports the PR #61. This PR changes the way the author is displayed in a list or single post, and also adds the functionality to display reading time and word count.
-rw-r--r--CONTRIBUTORS.md1
-rw-r--r--features.md11
-rw-r--r--i18n/en.yaml6
-rw-r--r--layouts/_default/list.html14
-rw-r--r--layouts/_default/single.html12
-rw-r--r--layouts/index.html21
-rw-r--r--layouts/partials/post_meta.html24
-rw-r--r--static/css/main.css9
8 files changed, 57 insertions, 41 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index de6b885..6f7722d 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -15,3 +15,4 @@ collaboration of others.
* [Mattia Panzeri](https://github.com/panz3r)
* [Jörg Thalheim](https://github.com/Mic92)
* [David Kaufmann](https://github.com/davidkaufmann)
+* [Sarath Chandra Mekala](https://github.com/sarathmekala)
diff --git a/features.md b/features.md
index 373633b..e4077ab 100644
--- a/features.md
+++ b/features.md
@@ -17,7 +17,9 @@
- .Site.Params.avatar # Add a avatar to your website
- .Site.Params.subtitle # Add a subtitle to your website
- .Site.Params.social # Add different social links to your website
- - .Site.Params.listAuthor # Activate to show authors of pages if available
+ - .Site.Params.readingTime # Show reading time for a post
+ - .Site.Params.wordCount # Show word count for a post
+ - .Site.Params.hideAuthor # Show author for a post
- .Site.Params.excludedTypes # Exclude specific types in lists
- .Site.Params.mainSections # Add list of sections that should show up on the homepage
- .Site.Params.nofeedSections # Add list of sections/types that should not be considered by RSS
@@ -32,13 +34,14 @@
- .Params.tags # https://gohugo.io/variables/page/#page-level-params
- .Params.nofeed # Don't add page to RSS file
- .Params.math # Add math typesetting with KaTeX to a specific page
- - .Params.author # Add the author of a page (recommended with .Site.Params.listAuthor)
- - .Params.authorlink # Add the create a link to a page of the author (recommended with .Site.Params.listAuthor)
+ - .Params.author # Add the author of a page
+ - .Params.authorlink # Add the create a link to a page of the author
- .Params.notaxonomy # Don't show this list of taxnomoies below the content
- .Params.type # https://gohugo.io/content-management/types/
- .Params.commentable # Enable/Disable comments for this specific page
- - .Params.hidden # Hide pages from the mainSections on the homepage
+ - .Params.hidden # Hide page from the mainSections on the homepage
- .Params.norobots # Disallow page in robots.txt for search engines
- .Params.nodate # Hide the publish date of specific content
- .Params.image # Add an image to the post
- .Params.imagetext # Add alternate text for the image to the post
+ - .Params.hidemeta # Hide the metadata (readingTime, wordCount and Author)
diff --git a/i18n/en.yaml b/i18n/en.yaml
index 79a669f..ce7d345 100644
--- a/i18n/en.yaml
+++ b/i18n/en.yaml
@@ -16,3 +16,9 @@
- id: 404text
translation: "There is not content here."
+
+- id: minutes
+ translation: "minutes"
+
+- id: words
+ translation: "words"
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 437dfb6..3034fbb 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -20,17 +20,9 @@
<div class="matter">
<article>
<h3 class="title small"><a href="{{ .RelPermalink }}">{{.Title}}{{ if .Draft }}<sup class="draft-label">DRAFT</sup>{{ end }}</a></h3>
-{{- if eq .Site.Params.listAuthor true }}
-<div class="author">
-{{- if isset .Params "author" -}}
-{{- if isset .Params "authorlink" -}}
-{{ i18n "authorpretext" }} <a href="{{ relURL .Params.authorlink }}" target="_blank" rel="noopener noreferrer">{{ .Params.author }}</a>
-{{- else -}}
-{{ i18n "authorpretext" }} {{ .Params.author }}
-{{- end -}}
-{{- end -}}
-</div>
-{{- end }}
+<p class="post-meta">
+{{ partial "post_meta.html" . }}
+</p>
<span class="description">{{ if isset .Params "description" }}{{ .Description }}{{ else }}{{ .Plain | htmlUnescape | safeHTML | truncate 140 }}{{ end }}</span>
</article>
</div>
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 5f0e03e..b2d6300 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -6,13 +6,6 @@
<img src="{{ index .Params.images 0 | relURL }}" {{ if isset .Params "imagetext" }}alt="{{ .Params.imagetext }}"{{ end }}>
</div>
{{- end }}
-<div class="author">
-{{- if eq .Site.Params.listAuthor true}}
-{{- if isset .Params "author" }}
-<p>{{ if isset .Params "authorlink" }}{{ i18n "authorpretext" }} <a href="{{ relURL .Params.authorlink }}" target="_blank" rel="noopener noreferrer">{{ .Params.author }}</a>{{- else }}{{ i18n "authorpretext" }} {{ .Params.author }}{{ end }}</p>
-{{- end }}
-{{- end }}
-</div>
<div class="post-header">
{{- if ne .Date.Year 1 }}
<div class="meta">
@@ -26,6 +19,11 @@
{{- end }}
<div class="matter">
<h1 class="title">{{ .Title }}</h1>
+{{- if not .Params.hidemeta }}
+<p class="post-meta">
+{{ partial "post_meta.html" . }}
+</p>
+{{- end }}
</div>
</div>
<div class="markdown">
diff --git a/layouts/index.html b/layouts/index.html
index 95ebb97..02db8e5 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -7,13 +7,6 @@
<img src="{{ index .Params.images 0 | relURL }}" {{ if isset .Params "imagetext" }}alt="{{ .Params.imagetext }}"{{ end }}>
</div>
{{- end }}
-<div class="author">
-{{- if eq .Site.Params.listAuthor true}}
-{{- if isset .Params "author" }}
-<p>{{ if isset .Params "authorlink" }}{{ i18n "authorpretext" }} <a href="{{ relURL .Params.authorlink }}" target="_blank" rel="noopener noreferrer">{{ .Params.author }}</a>{{- else }}{{ i18n "authorpretext" }} {{ .Params.author }}{{ end }}</p>
-{{- end }}
-{{- end }}
-</div>
<div class="post-header">
{{- if ne .Date.Year 1 }}
<div class="meta">
@@ -67,17 +60,9 @@
<div class="matter">
<article>
<h3 class="title small"><a href="{{ .RelPermalink }}">{{.Title}}{{ if .Draft }}<sup class="draft-label">DRAFT</sup>{{ end }}</a></h3>
-{{- if eq .Site.Params.listAuthor true }}
-<div class="author">
-{{- if isset .Params "author" -}}
-{{- if isset .Params "authorlink" -}}
-{{ i18n "authorpretext" }} <a href="{{ relURL .Params.authorlink }}" target="_blank" rel="noopener noreferrer">{{ .Params.author }}</a>
-{{- else -}}
-{{ i18n "authorpretext" }} {{ .Params.author }}
-{{- end -}}
-{{- end -}}
-</div>
-{{- end }}
+<p class="post-meta">
+{{ partial "post_meta.html" . }}
+</p>
<span class="description">{{ if isset .Params "description" }}{{ .Description }}{{ else }}{{ .Plain | htmlUnescape | safeHTML | truncate 140 }}{{ end }}</span>
</article>
</div>
diff --git a/layouts/partials/post_meta.html b/layouts/partials/post_meta.html
new file mode 100644
index 0000000..abcec6f
--- /dev/null
+++ b/layouts/partials/post_meta.html
@@ -0,0 +1,24 @@
+<span class="post-meta">
+{{ if .Site.Params.readingTime }}
+&nbsp;<i class="fas fa-clock"></i>&nbsp;{{ .ReadingTime }}&nbsp;{{ i18n "minutes" }}
+{{ end }}
+{{ if .Site.Params.wordCount }}
+{{ if .Site.Params.readingTime }} <!-- Add a separator between readingTime and WordCount if readingTime is enabled -->
+&nbsp;| &nbsp;
+{{ end }}
+<i class="fas fa-book"></i>&nbsp;{{ .WordCount }}&nbsp;{{ i18n "words" }}
+{{ end }}
+{{ if not .Site.Params.hideAuthor }}
+{{ if isset .Params "author" }}
+{{ if or (.Site.Params.wordCount) (.Site.Params.readingTime) }} <!-- Add a separator before author if either readingTime or WordCount is enabled -->
+&nbsp;|&nbsp;
+{{ end }}
+<i class="fas fa-user"></i>&nbsp;
+{{ if isset .Params "authorlink" }}
+<a href="{{ relURL .Params.authorlink }}" target="_blank" rel="noopener noreferrer">{{ .Params.author | safeHTML }}</a>
+{{ else }}
+{{ .Params.author | safeHTML }}
+{{ end }}
+{{ end }}
+{{ end }}
+</span>
diff --git a/static/css/main.css b/static/css/main.css
index 1e88501..3ce386f 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -395,7 +395,7 @@ table th {
}
.post .title.small {
- margin: 0 0 10px 0;
+ margin: 0;
font-family: "Roboto Slab Regular", serif;
}
@@ -438,6 +438,13 @@ table th {
margin-bottom: 0;
}
+.post-meta {
+ color: var(--hover-color);
+ font-size: 14px;
+ font-style: italic;
+ margin: 0 0 10px;
+}
+
.pagination {
margin: 0;
padding: 0;