Forum

Thread tagged as: Configuration, Discussion, Runway

Using Runway as Headless CMS and static site generators

Hi, I'm looking into the option of building a site using a static site generator (Gatsby) and pairing it with Runway as a Headless CMS. However, the sticking point is going be rebuilding the static site, and then publishing it when the user updates the content in the Perch backend. Anyone any experience of this? I fear there's no simple solution to this out there at the moment.

If not I may either have to build the site using Headless Runway with next.js or similar - or use a CMS that has this built in (such as Netlify CMS). I'd really rather not have to get to know another CMS having worked with Perch for years (whilst loving it) so hoping there may be a solution or pointers out there to assist!

Drew / Rachel is there anything in the pipeline at all for this? Guessing it's not such a requested feature, but the JAMstack seems to be gaining traction so may be requested more in the future?

Thanks.

Joe Proctor

Joe Proctor 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Could you listen for one of the publish events and then trigger your build? https://docs.grabaperch.com/api/events/list/

Maybe, way out of my comfort zone though! I'll take a look if I have spare time. I'll go down the next.js route for now.

Just a quick one on Headless Runway, am I right in assuming that all content that is available on a normal Perch Runway site is available via the API? Docs only really mention Collections, but I assume Pages and their regions are also gettable?

So where we use 'ContentCollections' in

$Collections = $API->get('ContentCollections')

is there a list of the other available parameters here?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use $API->get('ContentRegions') to work with regular content regions.

An example might be:

<?php

    $Headless   = $API->get('HeadlessAPI');
    $Response   = $Headless->new_response();

    $Regions = $API->get('ContentRegions');

    $Set = $Headless->new_set('regions');

    $Set->add_items($Regions->query('Stories', [
            'page' => '/news',
        ]));

    $Response->add_set($Set);   

    if ($Set->length == 0) {
        $Response->set_status('empty'); // HTTP 204
    }

    $Response->respond();

You can check also https://www.codigeeks.com