Remove line number from post snippet (#51).
Involves: - Home page - relate posts - search results - feed
This commit is contained in:
parent
3f843f010a
commit
ac9dc4d9ac
5 changed files with 25 additions and 4 deletions
12
_includes/no-linenos.html
Normal file
12
_includes/no-linenos.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{% comment %}
|
||||||
|
Remove line numbers from code snippets.
|
||||||
|
v2.2
|
||||||
|
https://github.com/cotes2020/jekyll-theme-chirpy
|
||||||
|
© 2020 Cotes Chung
|
||||||
|
Published under the MIT License
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% 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 %}
|
|
@ -58,7 +58,9 @@
|
||||||
</span>
|
</span>
|
||||||
<h3 class="pt-0 mt-1 mb-3" data-toc-skip>{{ post.title }}</h3>
|
<h3 class="pt-0 mt-1 mb-3" data-toc-skip>{{ post.title }}</h3>
|
||||||
<div class="text-muted small">
|
<div class="text-muted small">
|
||||||
<p>{{ post.content | markdownify | strip_html | truncate: 200 | replace: '&', '&' }}</p>
|
{% assign content = post.content %}
|
||||||
|
{% include no-linenos.html %}
|
||||||
|
<p>{{ content | markdownify | strip_html | truncate: 200 | replace: '&', '&' }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -15,7 +15,9 @@ layout: page
|
||||||
</h1>
|
</h1>
|
||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
<p>
|
<p>
|
||||||
{{ post.content | strip_html | truncate: 200 | replace: '&', '&' }}
|
{% assign _content = post.content %}
|
||||||
|
{% include no-linenos.html %}
|
||||||
|
{{ _content | markdownify | strip_html | truncate: 200 }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@ layout: compress
|
||||||
"categories": "{{ post.categories | join: ', '}}",
|
"categories": "{{ post.categories | join: ', '}}",
|
||||||
"tags": "{{ post.tags | join: ', ' }}",
|
"tags": "{{ post.tags | join: ', ' }}",
|
||||||
"date": "{{ post.date }}",
|
"date": "{{ post.date }}",
|
||||||
"snippet": "{{ post.content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}"
|
{% assign content = post.content %}
|
||||||
|
{% include no-linenos.html %}
|
||||||
|
"snippet": "{{ content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}"
|
||||||
}{% unless forloop.last %},{% endunless %}
|
}{% unless forloop.last %},{% endunless %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
|
|
5
feed.xml
5
feed.xml
|
@ -50,7 +50,10 @@ layout: compress
|
||||||
{% if post.summary %}
|
{% if post.summary %}
|
||||||
<summary>{{ post.summary | strip }}</summary>
|
<summary>{{ post.summary | strip }}</summary>
|
||||||
{% else %}
|
{% else %}
|
||||||
<summary>{{ post.content | strip_html | truncate: 200 }}</summary>
|
<summary>
|
||||||
|
{% assign content = post.content %}
|
||||||
|
{% include no-linenos.html %}
|
||||||
|
{{ content | strip_html | truncate: 200 }}</summary>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</entry>
|
</entry>
|
||||||
|
|
Loading…
Reference in a new issue