lektor / lektor

The lektor static file content management system

Home Page:https://www.getlektor.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to paginate data from databags?

thepabloaguilar opened this issue · comments

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.

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).

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