BeaconCMS/beacon

Page Builder: Reading time component

leandrocp opened this issue · 1 comments

Provide a component to display a "reading time" component as:

<BeaconWeb.Components.reading_time />

That component should return the amount in minutes, in the the example below it would return the value 8. Formatting is up to who is building the page.

Use the following logic to calculate the reading time:

WORDS_PER_MINUTE = 270
estimated_time_in_minutes = trunc((String.split(content, " ") |> length()) / WORDS_PER_MINUTE)

That formula needs the page content but a component doesn't have access to such value, so it will require adding the page path in the LiveView process as:

Process.put(:__beacon_page_path__, path)

Similar to

Process.put(:__beacon_site__, site)

Then in the component you're able to lookup the route from that path.

267784944-92ac567b-4c7a-431f-80b9-4a7207eec27b