Skip to content

Instantly share code, notes, and snippets.

@wvuwebgist
Created January 23, 2021 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvuwebgist/29b9ba11dbede01dec7a10e5395ca30e to your computer and use it in GitHub Desktop.
Save wvuwebgist/29b9ba11dbede01dec7a10e5395ca30e to your computer and use it in GitHub Desktop.
Assign the tags/labels you want to pull dynamically via Custom Data in CleanSlate CMS using Liquid.
---
layout: default
custom_data_attributes:
- tags_to_pull
---
<!--
Step 1: ☝️ Add the `tags_to_pull` custom data attribute to the
page template you want to output the feed on.
-->
<h2>Configuring tags/labels to pull dynamically via Custom Page Data</h2>
{% assign blog = site | get_page: 1234 %} <!-- Step 2: 👈 Change the ID to your blog index's page ID -->
{% assign articles = blog.articles | filter_articles: tags: page.data.tags_to_pull, limit: 5 %}
{% for article in articles.all %}
<ul>
<li><a href="{{ article.url }}">{{ article.name }}</a></li>
</ul>
{% endfor %}
<!-- For more background, see: https://github.com/wvuweb/cleanslate-cms/issues/256 -->
<!--
NOTE: We don't have to assign our custom data to a variable
because variables & custom data are properly scoped in liquid.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment