Search links and pagination in data objects of wp-source

Roadmap Card


Right now themes need to include a lot of verbose code in their pagination and search pages using libraries.source just to get:

  • query
  • if it is a search
  • the search query
  • page
  • path
  • next page link
  • previous page link

It doesn’t make sense. Frontity themes should be easy to create.

User Stories

As a Frontity theme developer
I want to access pagination and search in the data objects
so that I don’t have to repeat the same code over and over on all my themes

Possible solution

Let’s improve searches and pagination by adding:

  • For all entities:
    • data.query
  • For searches:
    • data.isSearch
    • data.searchQuery
  • For archives:
    • data.path
    • data.previous

Luis said in the PR:

I’ve found that when you pass down data like this:

<Post data={data} />

it feels a bit weird to know everything about the post (the type , the id , the isPost …) but to get the link you have to go somewhere else to get it:

const id =; 
const type = data.type; 
const isPost = data.isPost; 
const link = state.source[data.type][].link // <-- feels overcomplicated.

or you have to pass it down along with data :

so I thought it made sense to store it in along with the rest of the properties.

I agree with the reasoning :+1: