Navigation between adjacent posts

59 views
Skip to first unread message

Kyle Marek-Spartz

unread,
May 18, 2014, 3:11:39 PM5/18/14
to hak...@googlegroups.com
Hello,

Has anyone put together a way to go between adjacent posts? Next, previous? If this doesn’t work, I’ll probably just put a recent posts partial on the side of my posts template.

Kyle Marek-Spartz

richard...@gmail.com

unread,
Jul 6, 2014, 12:05:19 AM7/6/14
to hak...@googlegroups.com
I figured out one way to do this.

I added a $nextPost$, $prevPost$ fields to a Context, using a function nextPostUrl :: Item String -> Compiler String.
See the commit above for more details, but you can get the Identifiers of the posts using getMatches, get the identifier (maybe) before/after the Identifier of an Item, and can use an Identifier to get a Url.

If you wanted as well the next/prev post titles, I imagine a solution would be similar to this.

I also imagine it'd be possible to achieve the prev/next Urls with the Paginate functionality build into Hakyll.. although, I think you'd have to "adapt" buildPaginate since it doesn't sort Identifiers when it paginates.


Hope this is helpful if anyone else happens to wonder the same later..

Regards,
Richard

Jasper Van der Jeugt

unread,
Jul 8, 2014, 4:26:45 AM7/8/14
to hak...@googlegroups.com
Looks like someone just wrote a tutorial on that!

http://rgoulter.com/blog/posts/programming/2014-07-06-adding-nextprevious-post-to-hakyll.html

Hope this helps,
Peace,
Jasper
> --
> You received this message because you are subscribed to the Google Groups "hakyll" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jasper Van der Jeugt

unread,
Jul 8, 2014, 4:27:41 AM7/8/14
to hak...@googlegroups.com
Oh, I didn't see your mail here Richard.

Thanks a lot for the tutorial and the blogpost!

Peace,
Jasper

On Sat, Jul 05, 2014 at 09:05:18PM -0700, richard...@gmail.com wrote:
> I figured out one way to do this.
> https://github.com/rgoulter/my-hakyll-blog/commit/a4dd0513553a77f3b819a392078e59f461d884f9
>
> I added a $nextPost$, $prevPost$ fields to a Context, using a function nextPostUrl
> :: Item String -> Compiler *String**.*
> See the commit above for more details, but you can get the Identifiers of
> the posts using getMatches, get the identifier (maybe) before/after the
> Identifier of an Item, and can use an Identifier to get a Url.
>
> If you wanted as well the next/prev post titles, I imagine a solution would
> be similar to this.
>
> I also imagine it'd be possible to achieve the prev/next Urls with the
> Paginate functionality build into Hakyll.. although, I think you'd have to
> "adapt" buildPaginate since it doesn't sort Identifiers when it paginates.
>
>
> Hope this is helpful if anyone else happens to wonder the same later..
>
> Regards,
> Richard
>
>
> On Monday, May 19, 2014 7:11:39 AM UTC+12, Kyle Marek-Spartz wrote:
> >
> > Hello,
> >
> > Has anyone put together a way to go between adjacent posts? Next,
> > previous? If this doesn’t work, I’ll probably just put a recent posts
> > partial on the side of my posts template.
> >
> > –
> > Kyle Marek-Spartz
> >
>
Reply all
Reply to author
Forward
0 new messages