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

FR: Add option to add Word Count to metadata #735

Closed
thiagowfx opened this issue Jan 14, 2022 · 2 comments · Fixed by #740
Closed

FR: Add option to add Word Count to metadata #735

thiagowfx opened this issue Jan 14, 2022 · 2 comments · Fixed by #740
Assignees

Comments

@thiagowfx
Copy link
Contributor

thiagowfx commented Jan 14, 2022

In addition to showReadingTime ("5 min"), it would be handy to have native support for showWordCount or similar ("100 words").

Rationale: Reading time is subjective and relative. Word count is absolute and a more reliable and traditional proxy to estimate how long a post is. It's not perfect, and there are variations across languages, hence an option would leave it to users to decide whether it's relevant to their use cases.

Proof-of-concept

It basically comes down to adding the following snippet to post_meta.html:

{{- if (.Param "ShowWordCount") -}}
{{- $scratch.Add "meta" (slice (i18n "words" .WordCount | default (printf "%d words" .WordCount))) }}
{{- end }}

...plus adding translations for "words".

And the metadata looks something like:

December 11, 2021 · 1 min · 28 words · Thiago Perrotta

Happy to send a more polished PR than the aforementioned commit if the developers are willing to accept this contribution.

@adityatelange
Copy link
Owner

Hi @thiagowfx
Sure we can add this, please go ahead with a PR

@thiagowfx
Copy link
Contributor Author

c.f. #740

@adityatelange adityatelange linked a pull request Jan 21, 2022 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants