Api de Tempo estimado de Leitura de Artigo / Estimated reading time?

Answered

8 Comments

  • Brett - Community Manager
    Comment actions Permalink

    Hey Roger,

    There's no API endpoint that would capture the estimated reading time for an article, unfortunately.

    You'd most likely need to use some custom script in your Help Center theme and manually put these numbers in for each of your articles.

    Let me know if you have additional questions for me.

    Cheers!

    0
  • Simon Celen
    Comment actions Permalink

    Hi Roger,

    There is no specific feature for that but you could use Javascript to

    1. count the words in the article
    2. calculate the time needed based on an average reading speed of 200 words / minute. 
    3. inject that time in the article header
    var word_count = $('div.article-body').text().split(' ').length;
    var average_words_per_minute = 200;
    var estimated_reading_time = Math.ceil(word_count / average_words_per_minute); // rounding up

    $('div.article-meta ul.meta-group').append('<li class="meta-data">Estimated reading time: ' + estimated_reading_time + ' minutes</li>');

    ... which gives us something like:

     

    There are probably more scientific ways to calculate the estimated reading time based on average word length and number of stop words, there may also be different rules for different languages, ... but this snippet should get you started at least.

    Get in touch if you need help implementing something like this.

    0
  • Roger Drumond
    Comment actions Permalink

    Ola Simon Celler.

    Can you give me exactly where you injected the script?
    
    Was it in the Help Center layout template or article font?
    0
  • Simon Celen
    Comment actions Permalink

    Hi Roger,

    This would be in the theme's script.js file. 

    More info on editing your theme: https://support.zendesk.com/hc/en-us/articles/203664326-Customizing-your-Help-Center-theme-Guide-Professional-and-Enterprise-

    Specifically of interest is the "Customizing the CSS or JavaScriptCustomizing the CSS or JavaScript" section.

    Hope that helps

    0
  • Brett - Community Manager
    Comment actions Permalink

    Thanks for sharing Simon!

    0
  • Roger Drumond
    Comment actions Permalink

    Ola Simon Celen.

    Thank you for the informations.

     

    I inserted as per your instructions.

     

    But it had no effect. See the article: https://ajuda.sankhya.com.br/hc/pt-br/articles/360034964374

     

    Did not display reading time information.

    What did I do wrong?

     

    Thanks!

    0
  • Simon Celen
    Comment actions Permalink

    Hi Roger,

    There are a number of Javascript issues in your scripts.js file unfortunately. They prevent correct execution of the script.

    It's a bit out of scope for this board to fix those issues. However, it seems the theme was created by "Customer Support Theme", so it may be good to get in touch with them.

    0
  • Roger Drumond
    Comment actions Permalink

    Thank You Guys!

    The contribution was of great value.

    0

Please sign in to leave a comment.

Powered by Zendesk