Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reading time: #209

Merged
merged 3 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add reading time:
* Add new reading time partial
* Add conditional block for reading time in content layout
* Add new config param in userguide config.toml
* Remove reading time from specific page using front matter field
  • Loading branch information
Alex Earnshaw committed Feb 19, 2020
commit bf92ce6ae94af4b5cd24ab1c54feabe860ef93ef
5 changes: 4 additions & 1 deletion layouts/_default/content.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div class="td-content">
<h1>{{ .Title }}</h1>
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
{{ .Content }}
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable) (.Site.GoogleAnalytics)) }}
{{ partial "feedback.html" .Site.Params.ui.feedback }}
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/reading-time.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class="reading-time"><i class="fa fa-clock" aria-hidden="true"></i> {{ .ReadingTime }} minute read</p>
6 changes: 6 additions & 0 deletions userguide/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ enable = true
yes = 'Glad to hear it! Please <a href="https://github.com/USERNAME/REPOSITORY/issues/new">tell us how we can improve</a>.'
no = 'Sorry to hear that. Please <a href="https://github.com/USERNAME/REPOSITORY/issues/new">tell us how we can improve</a>.'

# Adds a reading time to the top of each doc.
# If you want this feature, but occasionally need to remove the Reading time from a single page,
# add "hide_readingtime: true" to the page's front matter
[params.ui.readingtime]
enable = true

[params.links]
# End user relevant links. These will show up on left side of footer and in the community page if you have one.
[[params.links.user]]
Expand Down
1 change: 1 addition & 0 deletions userguide/content/en/docs/Adding content/lookandfeel.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "Look and Feel"
linkTitle: "Look and Feel"
hide_readingtime: true
date: 2017-01-05
weight: 2
description: >
Expand Down