This repository contains code accompanying my blog post about generating directed graphs using Graphviz visualizing a Contentful space's structured content (entries and assets).
Have a look at the examples folder for an already exported Contentful space containing the Contentful example apps space data. This json file can used to try this tool without you exporting your own space data first:
node src/index.js examples/space.cf-example-app.json | dot -o graph.svg -T svg -K neato
graph.svg:
First, download this repository and install all dependencies:
git clone https://github.com/DanweDE/contentful-content-graphs-graphviz.git
cd contentful-content-graphs-graphviz
npm install
To better follow the blog post you can checkout the respective branch for each step,
e.g. git checkout blog-post/step-3
.
To export a Contentful space of your choice to work with, run
node util/export-space.js --file=space.json --space=CF_SPACE_ID --token=CF_CMA_TOKEN
or use the Contentful export tool cli directly.
With the space.json created in this folder you can run:
node src/index.js space.json
This takes the previous step's space.json and prints the dot markup for a graph.
The generated dot markup can either be copy pasted to viz-js.com or it can be processed by a local Graphviz installation:
node src/index.js | dot -o graph.svg -T svg -K dot
Instead of -K dot
any other Graphviz layout engine like neato
, fdp
or circo
can be used to influence the layout of the generated graph.