I wrote a tool for building routes.yaml files!

It’s very much beta at this point, but here it is!

Reports of invalid routing files appreciated. I still need to add some additional validation, but it should make it easier to generate the routes you want. Maybe?

Note: Not all themes respect routing. Source is particularly not routes.yaml friendly. Casper is a good option, if you want to try it.

No clue what I’m talking about? URLs & Dynamic Routing - Ghost Developer Docs

7 Likes

Love this! Thank you in advance from everyone!

1 Like

Neat tool!

Bug: limit is an unrecognised property for both routes, and collections.

Is ‘limit’ valid? It’s not in the docs. URLs & Dynamic Routing - Ghost Developer Docs

Guess I need to go read the source code! :slight_smile:

yep. not in the docs, but i’ve been using it to great affect for quite some time. let’s you override the posts_per_page value set in package.json on a per-collection basis.

i’ve discovered that all querying options for the get helper work in the routes file.

OK, so I learned something. As best I can tell, setting ‘limit’ in the routes file causes that route to return that number of posts, overriding the package.json posts_per_page. It doesn’t impact how many posts will be assigned to that route, just how many will be assigned to each page.

Which is interesting, but I’m not quite sure how I’d use it…

I use it to customise the number of posts. For example, I have a newsletter where I only want a single issue to be visible at any time. I can set the limit to 1 for that collection, and I do not need to build any custom index pages. I also use this to increase the number of posts visible on the index of my linkblog. Neat stuff.

Interesting. What besides limit are you using? I can see that it appears to accept include, status, visibility, and page also, but I’m not quite sure how that translates to building a collection.

Update: Of course, I use filter and order all the time! :slight_smile:

Ah, I see. Of course, it’s still there, just at (yourcollectionurl)/page/2 …

Snippet from my routes file:

collections:
  /blog/:
    data: tag.blog
    filter: primary_tag:blog
    permalink: /blog/{slug}/
  /scrapbook/:
    data: tag.scrapbook
    filter: primary_tag:scrapbook
    limit: 20
    permalink: /scrapbook/{slug}/
  /private-access/:
    data: tag.private-access
    filter: primary_tag:private-access
    limit: 1
    permalink: /private-access/{slug}/

I’m not seeing any effect of including a visibility (tried as visibility: members) or status (as status: draft)….