diff options
author | Frank Taillandier <frank@forestry.io> | 2020-02-02 00:42:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-02 00:42:29 +0300 |
commit | 5bb00a94a97b463da317389c0ebbbd9c40e047ea (patch) | |
tree | 6b4af0a1a76c6dd874fbf31d2101b57023c2d707 | |
parent | ee48c2010b39411f5299a81401addc596aaba3e7 (diff) | |
parent | f81c6e966231bbe190d82c73b0ce5c2f60e16a2d (diff) |
Merge pull request #16 from nicfits/implement-reading-time
Implement reading time
-rw-r--r-- | .forestry/front_matter/templates/post.yml | 14 | ||||
-rw-r--r-- | exampleSite/content/post/emoji-support.md | 7 | ||||
-rw-r--r-- | exampleSite/content/post/markdown-syntax.md | 4 | ||||
-rw-r--r-- | exampleSite/content/post/math-typesetting.mmark | 8 | ||||
-rw-r--r-- | exampleSite/content/post/placeholder-text.md | 1 | ||||
-rw-r--r-- | layouts/partials/article/hero.html | 4 | ||||
-rw-r--r-- | layouts/partials/article/next.html | 4 | ||||
-rw-r--r-- | layouts/partials/articles/list.html | 8 | ||||
-rw-r--r-- | layouts/partials/author/articles_list.html | 6 |
9 files changed, 20 insertions, 36 deletions
diff --git a/.forestry/front_matter/templates/post.yml b/.forestry/front_matter/templates/post.yml index 1fa6fcd..dd1b254 100644 --- a/.forestry/front_matter/templates/post.yml +++ b/.forestry/front_matter/templates/post.yml @@ -18,19 +18,9 @@ fields: description: '' config: required: false - date_format: - time_format: + date_format: + time_format: display_utc: false -- name: timeToRead - type: number - label: Read Time - description: The time it takes to read the post (in minutes) - default: 0 - config: - required: true - min: - max: - step: - name: hero type: file config: diff --git a/exampleSite/content/post/emoji-support.md b/exampleSite/content/post/emoji-support.md index ab97b3a..1c6774c 100644 --- a/exampleSite/content/post/emoji-support.md +++ b/exampleSite/content/post/emoji-support.md @@ -3,15 +3,14 @@ title: Emoji Support date: 2019-03-05 hero: "/images/hero-3.jpg" excerpt: Guide to emoji usage in Hugo -timeToRead: 8 authors: - Hugo Authors --- -Emoji can be enabled in a Hugo project in a number of ways. +Emoji can be enabled in a Hugo project in a number of ways. <!--more--> -The [`emojify`](https://gohugo.io/functions/emojify/) function can be called directly in templates or [Inline Shortcodes](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes). +The [`emojify`](https://gohugo.io/functions/emojify/) function can be called directly in templates or [Inline Shortcodes](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes). To enable emoji globally, set `enableEmoji` to `true` in your site’s [configuration](https://gohugo.io/getting-started/configuration/) and then you can type emoji shorthand codes directly in content files; e.g. @@ -45,4 +44,4 @@ font-family: Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,And } } </style> -{{< /css.inline >}}
\ No newline at end of file +{{< /css.inline >}} diff --git a/exampleSite/content/post/markdown-syntax.md b/exampleSite/content/post/markdown-syntax.md index c322865..f9b3b4e 100644 --- a/exampleSite/content/post/markdown-syntax.md +++ b/exampleSite/content/post/markdown-syntax.md @@ -3,7 +3,6 @@ title: Markdown Syntax Guide date: 2019-03-11 hero: "/images/hero-2.jpg" excerpt: Sample article showcasing basic Markdown syntax and formatting for HTML elements. -timeToRead: 10 authors: - Hugo Authors @@ -40,7 +39,7 @@ The blockquote element represents content that is quoted from another source, op #### Blockquote with attribution -> Don't communicate by sharing memory, share memory by communicating. +> Don't communicate by sharing memory, share memory by communicating. > — <cite>Rob Pike[^1]</cite> @@ -124,4 +123,3 @@ X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup> Press <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session. Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures. - diff --git a/exampleSite/content/post/math-typesetting.mmark b/exampleSite/content/post/math-typesetting.mmark index 5f83130..2c1f412 100644 --- a/exampleSite/content/post/math-typesetting.mmark +++ b/exampleSite/content/post/math-typesetting.mmark @@ -3,7 +3,6 @@ title: Math Typesetting date: 2019-03-08 hero: /images/hero-6.jpg excerpt: A brief guide to setup KaTeX -timeToRead: 8 authors: - Hugo Authors @@ -16,13 +15,13 @@ In this example we will be using [KaTeX](https://katex.org/) - Create a partial under `/layouts/partials/math.html` - Within this partial reference the [Auto-render Extension](https://katex.org/docs/autorender.html) or host these scripts locally. -- Include the partial in your templates like so: +- Include the partial in your templates like so: ```go {{ if or .Params.math .Site.Params.math }} {{ partial "math.html" . }} {{ end }} -``` +``` - To enable KaTex globally set the parameter `math` to `true` in a project's configuration - To enable KaTex on a per page basis include the parameter `math: true` in content files. @@ -43,6 +42,5 @@ Inline math: $$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$ Block math: $$ - \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } + \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$ - diff --git a/exampleSite/content/post/placeholder-text.md b/exampleSite/content/post/placeholder-text.md index 579e441..8e8a710 100644 --- a/exampleSite/content/post/placeholder-text.md +++ b/exampleSite/content/post/placeholder-text.md @@ -3,7 +3,6 @@ title: Placeholder Text date: 2019-03-09 hero: /images/hero-4.jpg excerpt: Lorem Ipsum Dolor Si Amet -timeToRead: 5 authors: - Hugo Authors diff --git a/layouts/partials/article/hero.html b/layouts/partials/article/hero.html index 16be937..f17f860 100644 --- a/layouts/partials/article/hero.html +++ b/layouts/partials/article/hero.html @@ -6,7 +6,7 @@ <div class="article-meta"> {{ partial "article/authors.html" . }} {{ .Page.Date.Format "January 2, 2006" }} - {{ with .Page.Params.timetoread }} • {{ . }} min read{{ end }} + • {{ .ReadingTime }} min read </div> </div> </header> @@ -16,4 +16,4 @@ </div> {{ end }} </div> -</section>
\ No newline at end of file +</section> diff --git a/layouts/partials/article/next.html b/layouts/partials/article/next.html index 5b5a895..fafb9ca 100644 --- a/layouts/partials/article/next.html +++ b/layouts/partials/article/next.html @@ -37,7 +37,7 @@ of the whole section and append them to our $next slice. */}} {{ if not $index}} id="article-link-bigger"{{ end }}> <div> <div class="image-container"> - <img src="{{ $article.Params.hero }}" class="article-image" /> + <img src="{{ $article.Params.hero }}" class="article-image" /> </div> <div> <h2 class="article-title"> @@ -47,7 +47,7 @@ of the whole section and append them to our $next slice. */}} {{ $article.Params.excerpt }} </p> <div class="article-metadata"> - {{ $article.Date | dateFormat "January 1, 2006" }}{{ with $article.Params.timeToRead }} · {{ $article.Params.timeToRead }} min read{{ end }} + {{ $article.Date | dateFormat "January 1, 2006" }} · {{ $article.ReadingTime }} min read </div> </div> </div> diff --git a/layouts/partials/articles/list.html b/layouts/partials/articles/list.html index 39ff17b..0ab9aa4 100644 --- a/layouts/partials/articles/list.html +++ b/layouts/partials/articles/list.html @@ -9,7 +9,7 @@ {{ if not $counter }} <div class="post-row"> {{ end }} - <a href="{{ $article.RelPermalink }}" class="article-link" + <a href="{{ $article.RelPermalink }}" class="article-link" {{ if and (eq ($biggerFirst) true) (eq ($biggerPlaced) false) }} {{ if eq $counter 0 }} id="article-link-bigger" @@ -23,7 +23,7 @@ {{ end }}> <div class="article-data-outer"> <div class="image-container"> - <img src="{{ $article.Params.hero }}" class="article-image" /> + <img src="{{ $article.Params.hero }}" class="article-image" /> </div> <div class="article-data"> <h2 class="article-title"> @@ -33,7 +33,7 @@ {{ $article.Params.excerpt }} </p> <div class="article-metadata"> - {{ $article.Date.Format "January 2, 2006" }}{{ if $article.Params.timetoread }} • {{ $article.Params.timetoread }} min read{{ end }} + {{ $article.Date.Format "January 2, 2006" }} • {{ $article.ReadingTime }} min read </div> </div> </div> @@ -52,4 +52,4 @@ {{ end }} </div> {{ partial "paginator/paginator.html" . }} -</section>
\ No newline at end of file +</section> diff --git a/layouts/partials/author/articles_list.html b/layouts/partials/author/articles_list.html index 604950d..58f5795 100644 --- a/layouts/partials/author/articles_list.html +++ b/layouts/partials/author/articles_list.html @@ -10,7 +10,7 @@ <a href="{{ .RelPermalink }}" class="article-link"> <div class="article-data-outer"> <div class="image-container"> - <img src="{{ .Params.hero }}" class="article-image" /> + <img src="{{ .Params.hero }}" class="article-image" /> </div> <div class="article-data"> <h2 class="article-title"> @@ -20,7 +20,7 @@ {{ .Params.excerpt }} </p> <div class="article-metadata"> - {{ .Date.Format "January 2, 2006" }}{{ if .Params.timetoread }} • {{ .Params.timetoread }} min read{{ end }} + {{ .Date.Format "January 2, 2006" }} • {{ .ReadingTime }} min read </div> </div> </div> @@ -36,4 +36,4 @@ </section> {{ $script := resources.Get "js/toggleBorder.js" }} -<script src="{{ $script.RelPermalink }}"></script>
\ No newline at end of file +<script src="{{ $script.RelPermalink }}"></script> |