Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

snip content for the front page?

26 views
Skip to first unread message

seven...@gmail.com

unread,
Jun 10, 2020, 4:56:49 PM6/10/20
to JBake Users
Hi, looking for how to render only some of the page content for the Index page of a blog. Still playing with the default init of a jbake project (installed the CLI with sdkman). I see in the docs an example of setting a "summary" in the blog post metadata, but that method seems to be limited to only one line and it would mean I duplicate my content there and in the body. Is there another approach to this?

Thanks,
Nick

Hrvoje Slaviček

unread,
Dec 16, 2020, 7:43:32 AM12/16/20
to JBake Users
Hi,

I am using a simple trick, and maybe it works for you. I am using thymleaf for templating engine. I use a divider  and than use substring funcion to show only first part of post as summary. 

In my posts I add a simple html  comment like this <!--more-->. This is a diveder betwene summery shown on posts index page and whole text that is shown on separate post page.

In my posts index template i have than this: 

<h2 class="subtitle is-4" th:text="${#dates.format(post.date, 'dd MMMM yyyy')}">December 25, 2018</h2>
<h1 class="title" th:text='${post.title}'>Title </h1>
<block th:utext='${#strings.substringBefore(post.body,"<!--more-->")}'>post block</block>
<br />
<a class="button is-outlined" th:href="${post.uri}">Read more</a>


I hope this helps. I banged my head how to solve this issue. 
Reply all
Reply to author
Forward
0 new messages