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

Statistics doesn't work in index.html #2

Open
athoune opened this issue Feb 1, 2025 · 0 comments
Open

Statistics doesn't work in index.html #2

athoune opened this issue Feb 1, 2025 · 0 comments

Comments

@athoune
Copy link

athoune commented Feb 1, 2025

Trouble

In article-info.html I have to test if stats is available :

{% if article.stats %}
<p title="~{{ article.stats['wc'] }} mots">~{{ article.stats['read_mins'] }} minutes de lecture</p>
{% endif %}

Stats are shown in articles page.
Without testing stats availability, pelican raise an exception.

Fix

The fix is easy, the generators_finalized signal must be used, too.

def register():
    """Register the Statistics plugin."""
    try:
        signals.all_generators_finalized.connect(run_plugin)
        signals.generators_finalized.connect(run_plugin)
    except AttributeError:
        # NOTE: This results in #314 so shouldn't really be relied on
        # https://github.com/getpelican/pelican-plugins/issues/314
        signals.content_object_init.connect(calculate_stats)

Do you want a pull-request (for a one line fix) ?

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

No branches or pull requests

1 participant