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

New Block: Time to Read #42542

Closed
bph opened this issue Jul 19, 2022 · 9 comments · Fixed by #43403
Closed

New Block: Time to Read #42542

bph opened this issue Jul 19, 2022 · 9 comments · Fixed by #43403
Assignees
Labels
[Block] Time to Read Affects the Time to Read Block Needs Design Needs design efforts. Needs Technical Feedback Needs testing from a developer perspective. New Block Suggestion for a new block

Comments

@bph
Copy link
Contributor

bph commented Jul 19, 2022

A Time to Read block would allow for site owners and theme builders to display the estimated time to read of the particular post or page to the frontend on single post templates or from within query loops in Archive templates.

Maybe the existing information form the table of contents panel can be stored into post meta key/value on save/publish action.
Screen Shot 2022-07-14 at 18 54 08

And then the Time To Read block displays the value, similar to the Post date or the post author.

@bph bph added New Block Suggestion for a new block Needs Technical Feedback Needs testing from a developer perspective. Needs Design Needs design efforts. labels Jul 19, 2022
@mtias
Copy link
Member

mtias commented Aug 5, 2022

Let's do it!

@t-hamano
Copy link
Contributor

If this block is expected by many, can I try to develop?
Technically, I believe this can be accomplished with a basic dynamic block implementation like Post Author Name block
If you see any potential problems in developing it, please advise me.🙂

@mtias
Copy link
Member

mtias commented Aug 18, 2022

That'd be great, feel free to start a branch and submit a proposal!

@t-hamano
Copy link
Contributor

Thank you!
Once the prototype is ready, I'd like to submit a PR as a proposal.

@t-hamano t-hamano self-assigned this Aug 19, 2022
@t-hamano
Copy link
Contributor

I am working on developing a block and have hit a major problem.
The Time To Read shown in the table of contents panel is a very complex process to calculate the time by count function from @wordpress/wordcount.

I think this block should be a dynamic block, so to match the numbers on this panel exactly, the same logic processing would need to be implemented in PHP.

Does anyone have any good ideas on this point?

@bph
Copy link
Contributor Author

bph commented Sep 6, 2022

@t-hamano It would be great if you could take on this new block.
I could see it to be a dynamic block, too, reading the value from post meta.
The Time-to-read information is calculated in the time-to-read component
Your block should be able to use the "minutesToReadString" and store in the post_meta table of the database before it's used for display?

Maybe this helps to get started?

@t-hamano
Copy link
Contributor

t-hamano commented Sep 8, 2022

@bph

Thanks for the advice!
Using the minutes calculated in the @wordpress/wordcount component in attributes would be a great way to match the calculated values with the info panel and block, or it would be very simple to implement.and block.

But, as was the concern with the ToC block, it cannot calculate dynamic time at render time. In other words, it would not work in the site editor (i.e., post templates such as single.html), but only in the post editor.

If we can accept this disadvantage, I would like to restart development 🙂

@phil-sola
Copy link

I came here today checking to see if this had already been requested or not.

Such a simple block, and very easy to implement I would imagine given the time to read component linked to above by @bph

+1 for this block!

@masteradhoc
Copy link
Contributor

@t-hamano thanks for your work! Hope this gets added soon!

@bph bph added the [Block] Time to Read Affects the Time to Read Block label Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Time to Read Affects the Time to Read Block Needs Design Needs design efforts. Needs Technical Feedback Needs testing from a developer perspective. New Block Suggestion for a new block
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants