Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions _includes/post-description.html

This file was deleted.

39 changes: 39 additions & 0 deletions _includes/post-summary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{%- comment -%}
Get the post's description or body content.

Arguments:
full_text: If true, return the full content. Default is false.
max_length: The maximum length of the returned content. Default is 200.
{%- endcomment -%}

{%- if post.description and include.full_text != true -%}
{{- post.description -}}
{%- else -%}
{%- comment -%} Remove the line numbers from the code snippet. {%- endcomment -%}

{%- assign content = post.content -%}

{%- if content contains '<td class="rouge-gutter gl"><pre class="lineno">' -%}
{%- assign content = content
| replace: '<td class="rouge-gutter gl"><pre class="lineno">',
'<!-- <td class="rouge-gutter gl"><pre class="lineno">'
-%}
{%- assign content = content | replace: '</td><td class="rouge-code">', '</td> --><td class="rouge-code">' -%}
{%- endif -%}

{%- assign content = content
| markdownify
| strip_html
| newline_to_br
| replace: '<br />', ' '
| strip_newlines
| strip
-%}

{%- unless include.full_text -%}
{%- assign max_length = include.max_length | default: 200 -%}
{%- assign content = content | truncate: max_length -%}
{%- endunless -%}

{{- content -}}
{%- endif -%}
2 changes: 1 addition & 1 deletion _includes/related-posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h3 class="mb-4" id="related-label">
{% include datetime.html date=post.date lang=include.lang %}
<h4 class="pt-0 my-2">{{ post.title }}</h4>
<div class="text-muted">
<p>{% include post-description.html %}</p>
<p>{% include post-summary.html %}</p>
</div>
</div>
</a>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<h1 class="card-title my-2 mt-md-0">{{ post.title }}</h1>

<div class="card-text content mt-0 mb-3">
<p>{% include post-description.html %}</p>
<p>{% include post-summary.html %}</p>
</div>

<div class="post-meta flex-grow-1 d-flex align-items-end">
Expand Down
2 changes: 1 addition & 1 deletion assets/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ permalink: /feed.xml
{% endfor %}
{% endif %}

<summary>{% include post-description.html max_length=400 %}</summary>
<summary>{% include post-summary.html max_length=400 %}</summary>

</entry>
{% endfor %}
Expand Down
3 changes: 2 additions & 1 deletion assets/js/data/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ swcache: true
"categories": {{ post.categories | join: ', ' | jsonify }},
"tags": {{ post.tags | join: ', ' | jsonify }},
"date": {{ post.date | jsonify }},
"content": {% include post-description.html json=true %}
{% capture content -%}{% include post-summary.html full_text=true %}{%- endcapture -%}
"content": {{ content | jsonify }}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]