Skip to content

Commit 2e14cfb

Browse files
committed
added logic to check for excerpt
1 parent bb6809a commit 2e14cfb

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

content/community/write-a-blog-post/contents.lr

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Once you have written your post, you can either send it to us (Markdown is easie
5454
---
5555
pub_date: Replace this text with the publication date in YYYY-MM-DD format.
5656
---
57+
excerpt: Replace this text with a short summary of your post. This is an optional, and you can leave it blank.
58+
---
5759
body:
5860
Replace this text with your post's content (minus the title). This field accepts Markdown for formatting.
5961
If you're including images, you can use the Markdown image syntax i.e. ![image-title](image-file-name.jpg).

models/blog-post.ini

+5
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ type = strings
2929
[fields.body]
3030
label = Body
3131
type = markdown
32+
33+
[fields.excerpt]
34+
label = Excerpt
35+
type = text
36+
width = 1/2

themes/vocabulary_theme/templates/macros/posts.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
<h4 class="b-header"><a class="blog-title" href="{{ post|url }}">{{ post.title }}</a></h4>
1010
{{ render_authors_byline(post) }}
1111
<div class="excerpt">
12-
{{ post.body | excerpt | string | striptags() | truncate(100) }}
12+
{% if post.excerpt %}
13+
{{ post.excerpt | string | striptags() }}
14+
{% else %}
15+
{{ post.body | excerpt | string | striptags() | truncate(100) }}
16+
{% endif %}
1317
</div>
1418
</div>
1519
</article>

0 commit comments

Comments
 (0)