Visualising
complex content models
contentful-graph
About me
Contentful
Contentful
Component 1:1 matching
Author
Category
Image
Photo Gallery
Component 1:1 matching
Author
Category
Image
Photo Gallery
Component 1:1 matching
Author
Category
Image
Photo Gallery
const PhotoGallery = ({ children }) => <div>{children}</div>
const Image = ({ src, author, category }) => <div>
<img src={src} />
<Category name={category} />
<Author name={author} />
</div>
const Category = ({ name }) => <h3>{name}</h3>
const Author = ({ name }) => <a href={`/users/${name}`}>{name}</a>
Component 1:1 matching - more components
Author
Parnter
Car
BlogAuthor
JobPosition
FAQAnswer
BlogPostList
PressCarousel
PressContaine
BlogPostList
Insurance
PressArticle
Feature
TwoColumnList
Feedback
CalculateEarnings
CarCarousel
FAQContainer
BrandedHero
FeaturesList
UserJourney
What to do?
Use Contentful API
API:
Content type definitions:
Understanding model relations
Mode field definitions:
"PressCarousel": {
"fields": [{
"id": "children",
"name": "Children",
"type": "Array",
"validations": [],
"items": {
"type": "Link",
"validations": [{
"linkContentType": [
"press"
]
}
],
"linkType": "Entry|Asset"
}
Understanding model relations
Mode field definitions:
Type of relationship:
"PressCarousel": {
"fields": [{
"id": "children",
"name": "Children",
"type": "Array",
"validations": [{
"linkMimetypeGroup": [
"image"
]
}
],
"items": {
"type": "Link",
"validations": [{
"linkContentType": [
"press"
]
Understanding model relations
Mode field definitions:
Type of relationship:
"PressCarousel": {
"fields": [{
"id": "children",
"name": "Children",
"type": "Array",
"validations": [],
"items": {
"type": "Link",
"validations": [{
"linkContentType": [
"press"
]
}
],
"linkType": "Entry|Asset"
}
Visualising connections
$ npx contentful-graph
digraph obj {� node[shape=record];�� Category ;� Author ;� Post ;
Author -> Post;� Post -> Author;� Post -> Category;�}
models.dot
Visualising connections
digraph obj {� node[shape=record];�� Category ;� Author ;� Post ;
Author -> Post;� Post -> Author;� Post -> Category;�}
models.dot
Graphviz
dot -Tpng > model.png
Visualising connections
digraph obj {� node[shape=record];�� Category ;� Author ;� Post ;
Author -> Post;� Post -> Author;� Post -> Category;�}
models.dot
Visualising connections - real world models
Visualising connections
But wait..
There’s more
contentful-graph-web
Thank you.