I'm making a website with Hakyll. I successfully created a RSS feed showing showing for each post the teaser section delimited by <!--more-->
.
My problem is that this teaser section is shown in the full (templated) pages of these posts. And I would like only that is after <!--more-->
and not before.
---
title: My Post
author: JeanJouX
date: 2016-09-06
tags: Haskell
---
The teaser of my post to be shown in the RSS feed. Not in the full page.
<!--more-->
The rest of the post to be shown in the full page of my website
Is it possible to do that with Hakyll?
I don't believe there is a method to do that built into Hakyll.
As I see it you have two options:
write a pass that strips the teaser from the document before rendering it on its own page
keep the teaser in the actual page, but use CSS to hide it
The first option is probably better, but requires mussing about with string manipulation and Hakyll compilers. If you want a place to start, take a look at the implementation of teaserFieldWithSeparator
which uses the needlePrefix
function from Hakyll.Core.Util.String
to extract the teaser from the document body. You'll have to do the opposite: extract everything but the teaser.
If you do take this approach, you could contribute it back into Hakyll, saving the effort for people who want to do the same thing in the future.
The other option is hackier but easier. You can wrap all your teasers in a div with some CSS class:
<div class="teaser">
Some text.
</div>
<!--more-->
Then, in your page template, add a CSS rule that hides the teaser paragraph:
.teaser {
display : none;
}
The text is still in the page's HTML so this is not an ideal solution, but you can make it work without needing to write any Hakyll code.