Get Started with Cockpit and Hammer

jamstack

#1

I’ve done a few written tutorials on building static CMS sites, using API-first CMS’s - the main one so far being Contentful.

But, Artur Heinze is doing a great job moving the open-source Cockpit product along.

Here’s a brief (or not so brief) screencast which:

  • Introduces Cockpit [00:00]
  • Shows you how to get started using Cockpit [05:40]
  • How to define content types or content models (Collections in Cockpit parlance) [10:08]
  • How to do a basic setup in Hammer to pull in content from Cockpit [15:10]
  • How to do a more advanced setup in Hammer to generate new content [23:50]

Total Running Time - 35 mins


#2

Is there a basic slim Hammer template available? I checked the Template Gallery without success.

Update:

I’ve mostly converted the Bootstrap 3 template using a mix of slim and HTML. However, it doesn’t work since the cockpit global variable isn’t found; Hammer kindly tells me that contentful is available.

I’ve run through your tutorial several times and I can’t see where I’ve messed up in defining “cockpit” in the hammer.json file.

Any help would be appreciated.


#3

@nospam Here’s a hammer project template, from which I created in the video.

https://dl.dropboxusercontent.com/u/10612698/Hammer%20Templates/cockpit-blog-starter.hammer

Replace the apiKey and apiUrl

You’ll need the same contentType structure for it to build, or you can use this Cockpit instance.

https://dl.dropboxusercontent.com/u/10612698/Cockpit%20Instances/cockpit-blog.zip


#4

Let me know what version of the compiler you are using too…

If earlier than 5.4.7.1, then I’d suggest updating using this auto-update script:


#5

That did it! Once I cranked through the auto-updater (and installed the necessary gems), it built and now is working fine!

Note also that the @todo support came back; it wasn’t working in slim files but now is.

Many thanks! Now to see about git integration and auto-publish as you did on the Contentful integration.


#6

Great stuff @nospam - I’ll do a follow up screencast for continuous deployments with cockpit this afternoon. But see how you get on…


#7

I keep getting an error:

757: unexpected token at '

I’m using the files from Dropbox above. Tried upgrading the Hammer compiler via Github (worked I think, no errors) and downloaded the beta here.

I updated the API key. And URL. Any ideas? Thanks!


#8

@adam1 can you confirm the compiler version that is running - can you get a simple project to build and check the version at bottom of files list view…


#9

There is a breaking change in a recent-ish Cockpit update that changes how the Cockpit REST API works. If you are getting the following error

Then you are not alone.

I have a feeling that this is the culprit

When we initialize cockpit in the hammer gem, we use the rest api to parse the entries. If the entry endpoint changes, we may well end up with nil, which is what this error suggests…

But I need to look into it in more detail, pull requests welcome