Skip to content

Add get_by_slug #2

@minchinweb

Description

@minchinweb

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions