Converting existing pages to use CMS data
We have a series of pages that need to have their content updated with the new data source. Anywhere in the project that we loop through collections.episodes
, we need to replace this with information from the hygraph.episodes
array.
Both the index.html
file and episodes.html
have a simple loop that needs to be replaced. Aside from needing to change the source of the data, we also need to adjust the variables used. While collection item data is stored under a data
key, this new data is directly in the episode
object. We also need to format the slug to use the /episodes/
prefix to link properly:
{% for episode in hygraph.episodes %} <h3><a href="/episodes/{{ episode.slug }}"> {{ episode.title }} </a></h3> {% endfor %}
Next, we need to update the JSON file that we use to form our Algolia...