Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for "lead section" #503

Open
OndraZizka opened this issue Jul 25, 2018 · 4 comments
Open

Support for "lead section" #503

OndraZizka opened this issue Jul 25, 2018 · 4 comments

Comments

@OndraZizka
Copy link
Contributor

OndraZizka commented Jul 25, 2018

On the index page(s), the template author can only use 1-line title, or the full content.

But it's a common practice to have lead section. Content authors then keep this in mind stylistically and treat the lead section as a bait for the reader.

This can be quite easily done - good markup languages support adding CSS classes to sections in some way. JBake could simply take the first //div[@class='leadParagraph']|//section[@class='leadParagraph']| and store it's inner HTML to an extra ODocument field.

Example in Texy:

New cool feature!
##############

/---section .(lead)
JBake has a new feature.
\---

Coming in next release.

Would you like that?

@OndraZizka
Copy link
Contributor Author

OndraZizka commented Jul 26, 2018

As a workaround, one could use this class to show that part and hide the rest, with a bit of JS tweaking, but the main issue would still be performance. Phones won't deal with the large DOM easily.

@jonbullock
Copy link
Member

I have seen some define the value for the lead in the metadata header for the file, not saying it's ideal but it's one solution.

@slavus
Copy link

slavus commented Jan 10, 2021

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 . This is a divider between 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.

@jonbullock
Copy link
Member

Thanks for taking the time to share your solution @slavus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants