Skip to content

Instantly share code, notes, and snippets.

@wvuwebgist
Last active March 4, 2021 23:09
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/023a0ef7bd5617bf6cea1b1555b0ab01 to your computer and use it in GitHub Desktop.
Save wvuwebgist/023a0ef7bd5617bf6cea1b1555b0ab01 to your computer and use it in GitHub Desktop.
CleanSlate (Liquid): Add a featured blog post to a page on your site.
{% assign blog = site | get_page: 1234 %} <!-- Change this ID to your blog_index page's ID -->
{% assign articles = blog.articles | filter_articles: tags: "featured", limit: 1 %}
{% for article in articles.all %}
<article class="wvu-article">
<h2 class="wvu-article__title"><a href="{{ article.url }}">{{ article.name }}</a></h2>
<p class="wvu-article__meta">
{{ article.author.full_name }} |
<time class="wvu-article__date" datetime="{{ article.published_at | date_iso8601 }}">{{ article.published_at | date: '%A, %B %d, %Y' }}</time>
</p> <!-- /.wvu-article__meta -->
<div class="wvu-article__body" itemprop="articleBody">
{{ article.content['article-body'] | select_html: css_selector: 'p', limit: 1 }}
</div> <!-- /.wvu-article__body -->
<p><a href="{{ article.url }}">Read Full Article</a></p>
</article> <!-- /.wvu-article -->
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment