Creating charts

Hi,

I want to include a yaml data structure in my markdown files and have have the data passed to a template for rendering.

Is this possible to do in Hugo?

Carl

Will these help? :

Dynamic content in the docs:
https://gohugo.io/extras/dynamiccontent/

Site search discussion about consuming json files:

Yes, maybe. However l was hoping to define the data for the charts in the markdown as yaml and have that passed to an rendered by the template.

Hmm, since you can access the yaml frontmatter from templates, I imagine you can access any structure in the frontmatter. You just need to write the correct code to extract it.

Perhaps you can give an example of your frontmatter and what you’ve tried?

So this is what I was thinking here. Basically need to extract the YAML front matter then render to a template that contains the config including JS libraries for the charts.

Heading 1

Chart 1 here


id: c1
categories: [cars, trains, buses, planes, trams]
competition:
comp1: [20, 8, 1, 2, 9]
comp2: [5, 8, 1, 2, 9]
comp3: [5, 8, 1, 2, 9]
comp4: [8, 5, 1, 2, 9]
comp5: [5, 8, 1, 2, 9]
comp6: [9, 9, 1, 2, 9]
comp7: [2, 5, 5, 5, 9]
comp8: [5, 8, 1, 2, 9]
comp9: [5, 5, 3, 3, 9]
comp10: [8, 5, 1, 2, 9]
title: Today
ven: [1,2,3,4,20]

Chart 2 here


id: c2
categories: [Horses, Cats, Dogs]
competition:
comp1: [5, 8, 1]
comp2: [5, 8, 1]
comp3: [5, 8, 1]
comp4: [8, 5, 1]
comp5: [5, 8, 1]
comp6: [9, 9, 1]
comp7: [2, 5, 5]
comp8: [5, 8, 1]
comp9: [5, 5, 3]
comp10: [8, 5, 1]
title: Future
ven: [5,4,3]

Chart 3 here


id: c3
categories: [Horses, Cats, Dogs]
competition:
comp1: [5, 8, 7]
comp2: [5, 8, 7]
comp3: [5, 8, 7]
comp4: [5, 5, 7]
comp5: [5, 8, 7]
comp6: [5, 9, 7]
comp7: [5, 5, 7]
comp8: [5, 8, 7]
comp9: [5, 5, 7]
comp10: [5, 5, 7]
title: Tomorrow
ven: [3,8,1]

Chart 4 here


id: c4
categories: [Boats, LandRovers]
competition:
comp1: [2, 8]
comp2: [2, 5]
comp3: [2, 5]
comp4: [2, 5]
comp5: [2, 8]
comp6: [2, 9]
comp7: [2, 5]
comp8: [2, 8]
comp9: [2, 5]
comp10: [2, 5]
title: Tomorrow
ven: [3,8]

Carl