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

How to paginate data from databags? #1150

Open
thepabloaguilar opened this issue Jun 26, 2023 · 2 comments
Open

How to paginate data from databags? #1150

thepabloaguilar opened this issue Jun 26, 2023 · 2 comments

Comments

@thepabloaguilar
Copy link

Hi, thanks for the amazing project! I'm trying to paginate data from a databag.

Basically I have a list with members like this:

{
  "members": [
    {
      "name": "First Name"
    },
    {
      "name": "Second Name"
    }
  ]
}

And I want to create a members page listing all but paginating them, how can I achieve that?

Thanks.

@dairiki
Copy link
Contributor

dairiki commented Jul 20, 2023

It sounds like what you're wanting to do is to generate a sequence of child pages from a data source (a databag, in this case), and then paginate those pages.

Lektor itself does not provide any built-in way to do that first step: generate pages programmatically from a data source.

I'm pretty sure it would be possible to write a plugin that would, e.g., provide a jinja global function to generate a series of virtual source objects from a data source. (Those virtual source objects would then be rendered to output pages.) If that function returns the sequence of virtual source objects in a form which provides enough of the interface of a Lektor database Query object (lektorlib.query.PrecomputedQuery might be helpful here), then it could be used in a replaced_with expression to provide the children of a page (which could then be paginated in the normal way).

@iainhallam
Copy link

@dairiki Sounds like this plugin - https://github.com/yargies/lektor-datapages - but I can't get this to work.

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

3 participants