{
  "name": "Generate social preview images",
  "nodes": [
    {
      "parameters": {},
      "id": "trigger",
      "name": "When clicking Execute",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// One item per article. 1200 x 630 px is 317.5 x 166.7 mm at 96 dpi.\nreturn [{ json: {\n  title: 'How to generate invoice PDFs without a server',\n  category: 'Automation',\n  author: 'Mara Vogt',\n  readingTime: 7,\n  logoUrl: 'https://www.customjs.space/images/logo.png',\n} }];"
      },
      "id": "article",
      "name": "Article",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "resource": "convert",
        "operation": "htmlToPdf",
        "pdfWidthMm": 317.5,
        "pdfHeightMm": 166.7,
        "outputFilenamePdf": "og-card.pdf",
        "html": "=<!DOCTYPE html>\n<html><head><meta charset=\"utf-8\"><style>\n  * { box-sizing: border-box; }\n  body { margin: 0; font-family: Inter, Arial, sans-serif; }\n  .card {\n    width: 1200px; height: 630px; padding: 72px;\n    background: linear-gradient(135deg, #4338ca, #2563eb);\n    color: #fff; display: flex; flex-direction: column; justify-content: space-between;\n  }\n  .kicker { font-size: 24px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.8; }\n  h1 {\n    font-size: 64px; line-height: 1.1; letter-spacing: -0.02em; margin: 24px 0 0;\n    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;\n  }\n  .meta { font-size: 24px; opacity: 0.85; }\n</style></head>\n<body>\n  <div class=\"card\">\n    <div>\n      <div class=\"kicker\">{{ $json.category }}</div>\n      <h1>{{ $json.title }}</h1>\n    </div>\n    <div class=\"meta\">{{ $json.author }} · {{ $json.readingTime }} min read</div>\n  </div>\n</body></html>"
      },
      "id": "render-card",
      "name": "Render card",
      "type": "@custom-js/n8n-nodes-pdf-toolkit-v2.pdfToolkit",
      "typeVersion": 1,
      "position": [
        440,
        0
      ],
      "credentials": {
        "customJsApi": {
          "id": "1",
          "name": "CustomJS account"
        }
      }
    },
    {
      "parameters": {
        "resource": "convert",
        "operation": "pdfToPng"
      },
      "id": "pdf-to-png",
      "name": "PDF to PNG",
      "type": "@custom-js/n8n-nodes-pdf-toolkit-v2.pdfToolkit",
      "typeVersion": 1,
      "position": [
        660,
        0
      ],
      "credentials": {
        "customJsApi": {
          "id": "1",
          "name": "CustomJS account"
        }
      }
    }
  ],
  "connections": {
    "When clicking Execute": {
      "main": [
        [
          {
            "node": "Article",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Article": {
      "main": [
        [
          {
            "node": "Render card",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Render card": {
      "main": [
        [
          {
            "node": "PDF to PNG",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}
