Cezanne

Cezanne

  • Introduction
  • Configuration
  • APIs

›Getting Started

Introduction

  • Understanding Cezanne

Getting Started

  • Configuration
  • Generating Images
  • Saving Images

Configuration

Make sure to read the introduction to Cezanne!

Cezanne automatically looks for a file called cezanne.config.json in the root of your project (where the package.json file is).
The file must be formatted as follows:

{
  "version": 0.1,
  "debug": true,
  "aws": {
    "access_key": "",
    "access_secret": "",
    "bucket_name": ""
  },
  "endpoints": {
    "articles": {
      "instagram": "",
      "linkedin": "",
      "opengraph": "",
      "twitter": ""
    }
  },
  "viewports": {
    "instagram": [1080, 1080],
    "linkedin": [1920, 1080],
    "opengraph": [1200, 630],
    "twitter": [1012, 506]
  }
}

Let's break down all the required keys:

KeyRequiredDescription
VersiontrueThe configuration version. Default is 0.1
DebugfalseWill print debug information to the console. Default is false
AWSfalseAWS credentials. Required to upload the resulting images to S3
EndpointstrueA list of endpoints. Every endpoint will generate a specific function (see forward)
ViewportstrueThe viewport to be set for every social image ([width, height])

Endpoints in depths

Let's dig deeper into the endpoints section:

{
  "endpoints": {
    "articles": {
      "instagram": "https://example.com/cezanne/articles/instagram/:postId/:slug",
      "linkedin": "https://example.com/cezanne/articles/linkedin/:postId/:slug",
      "opengraph": "https://example.com/cezanne/articles/opengraph/:postId/:slug",
      "twitter": "https://example.com/cezanne/articles/twitter/:postId/:slug"
    },
    "tags": {
      "instagram": "https://example.com/cezanne/tags/instagram/:postId/:slug",
      "linkedin": "https://example.com/cezanne/tags/linkedin/:postId/:slug",
      "opengraph": "https://example.com/cezanne/tags/opengraph/:postId/:slug",
      "twitter": "https://example.com/cezanne/tags/twitter/:postId/:slug"
    }
  }
}

Let's pretend that you just want to create social/open graph images for your blog posts and tags.
You'll need then to setup a route for every template that will be rendered and then captured by Cezanne.
As you can see, you'll also need to write down every dynamic parameter of your route (such as post id, post slug and so on).

Using Dhall

While Dhall is not currently supported (but will be in the future), we strongly encourage you to use it to generate your Cezanne configuration file.

let makeUrl = \(item : Text) ->
    let remote    = "https://example.com"
    let opengraph = "${remote}/opengraph"
    let instagram = "${remote}/instagram"
    let twitter   = "${remote}/twitter"
    let linkedin  = "${remote}/linkedin"
    in {
        instagram = "${instagram}/${item}/:id"
      , opengraph = "${opengraph}/${item}/:id"
      , twitter   = "${twitter}/${item}/:id"
      , linkedin  = "${linkedin}/${item}/:id"
     }

in {
       version   = 0.1
     , debug     = True
     , endpoints = {
       articles  = makeUrl "articles"
     , topics    = makeUrl "topics"
     , authors   = makeUrl "authors"
     , languages = makeUrl "languages"
    }
    ,
    viewports = {
        instagram = [1080, 1080]
      , opengraph = [1200, 630]
      , twitter   = [1012, 506]
      , linkedin  = [1920, 1080]
    }
    ,
    aws = {
        access_key    = ""
      , access_secret = ""
      , bucket_name   = ""
      , path          = "/path/example/:item/:id"
    }
   }
Last updated by Michele Riva
← Understanding CezanneGenerating Images →
  • Endpoints in depths
  • Using Dhall
Cezanne
Docs
IntroductionConfiguration
Community
User ShowcaseStack OverflowTwitter
More
BlogGitHubStar
Follow @hackdoor_io
Facebook Open Source
Copyright © 2020 Hackdoor.io