This method uses a special string, <!-- break -->
, to denote a breakpoint in index.html
:
{# Split the post into an array using explode().
Because we provide a length of 2, the "rest"
of the post will be stored in the second array
element, even if there are multiple breakpoints. #}
{% set break_array =
post.blocks.content|split('<!-- break -->', 2) %}
{# Output the first element of the array in raw mode #}
{{ break_array[0]|raw }}
{# Detect if there is more to the post. If the post
was only one array element with no breakpoints,
it would all have shown up. This Read More link should
only show up if there is overflow to the post. #}
{% if break_array|length > 1 %}
<div class="my-6"><a href="{{ site.url }}{{ post.url }}" class="p-2 rounded-md hover:bg-gray-500 hover:text-white">
Read more of this post »
</a></div>
{% endif %}
In the YAML front-matter, specify a custom parameter with an excerpt of text to display instead of the post content blocks.
---
layout: post
title: Who Watches the Watchmen?
date: 2018-02-22 22:59:59
image: img/sculpin-banner.png
tags: [sculpin]
categories: [coding, howto]
summary: "Presenting ideas on how to properly test the --watch parameter to site generation using the Symfony Process Component"
---
Then, in index.html
, instead of showing the post content blocks, you would output the summary:
{{ post.summary }}