Get page HTML via hubl

I’m trying to implement a read time feature where read time is generated via hubl for the current blog post. Was following this: HubSpot | Add Reading Minutes to Blog Post

However, currently “content.post_body” is returning nothing as we are using custom modules to populate the blog post and not the standard Blog Content/Rich Text module. Is there a way I can get the HTML of the whole page, or access the HTML in the other modules to then calculate the read time?

Hey @jonflynnh2o !

Might be worth looking at the developer info (in the sprocket dropdown)

You should get a JSON output of all of the data on the page.

@Anton or @alyssamwilie could probably help out more :wink:

Hi @jonflynnh2o,

I would try to concatenate all of the “rich-text” values into a single hubl like

{% set total_readtime = module.rich_text_1 ~ module.rich_text_2 ...%}

and then modify the read time code to this:

{% set initialPostWords = total_readtime|striptags|wordcount %}
{% set calculatedPostWords = (initialPostWords/100) * 100 %}
{% set finishedPostWords = calculatedPostWords|divide(300)|round(2) %}
{% set number = finishedPostWords|round %}
{% if number < 1 %}

{% else %}
 {{ finishedPostWords|round }} minute read
{% endif %}

Just a quick tipp: you should use the default “content.post_body” option somewhere in the post. Maybe for the “intro”. Otherwise you’ll need to rewrite module like “latest posts” or similar (all modules which displays some kind of blog information preview)

best,

Anton