Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add get_by_slug #2

Open
MinchinWeb opened this issue Jun 1, 2017 · 0 comments
Open

Add get_by_slug #2

MinchinWeb opened this issue Jun 1, 2017 · 0 comments

Comments

@MinchinWeb
Copy link
Member

This filter would allow you to do a reverse lookup based on the slug of the page you are looking for:

# custom Jinja2 filter
def get_by_slug(objs, slug):
    for obj in objs:
        if obj.slug == slug:
            return obj

JINJA_FILTERS = {
    "get_by_slug": get_by_slug,
}

https://siongui.github.io/2017/01/08/pelican-get-single-page-or-article-by-slug-metadata-in-theme/

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant