Code improvement.
Passing parameters to includes
This commit is contained in:
parent
562fcd4fd8
commit
209058b84a
7 changed files with 28 additions and 24 deletions
|
@ -3,7 +3,10 @@
|
|||
https://github.com/penibelst/jekyll-compress-html/issues/101
|
||||
https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901
|
||||
-->
|
||||
{% if _content contains '<pre class="highlight">' %}
|
||||
{% assign _content = _content | replace: '<pre class="highlight"><code', '<code' %}
|
||||
{% assign _content = _content | replace: '</code></pre>', '</code>' %}
|
||||
{% endif %}
|
||||
{% if include.content contains '<pre class="highlight">' %}
|
||||
{% assign content = include.content | replace: '<pre class="highlight"><code', '<code' %}
|
||||
{% assign content = content | replace: '</code></pre>', '</code>' %}
|
||||
{{ content }}
|
||||
{% else %}
|
||||
{{ include.content }}
|
||||
{% endif %}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
{% comment %}
|
||||
Remove line numbers from code snippets.
|
||||
Remove the line number of the code snippet.
|
||||
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">' %}
|
||||
{% assign content = include.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 %}
|
||||
|
|
|
@ -99,9 +99,10 @@
|
|||
</span>
|
||||
<h3 class="pt-0 mt-1 mb-3" data-toc-skip>{{ post.title }}</h3>
|
||||
<div class="text-muted small">
|
||||
{% assign content = post.content %}
|
||||
{% include no-linenos.html %}
|
||||
<p>{{ content | markdownify | strip_html | truncate: 200 | replace: '&', '&' }}</p>
|
||||
<p>
|
||||
{% include no-linenos.html content=post.content %}
|
||||
{{ content | markdownify | strip_html | truncate: 200 }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
|
|
@ -9,11 +9,14 @@
|
|||
<div class="col-12 col-xl-11 post-content">
|
||||
<div id="search-hints">
|
||||
<h4 class="text-muted mb-4">{{ site.data.label.panel.trending_tags }}</h4>
|
||||
|
||||
{% include trending-tags.html %}
|
||||
|
||||
{% for tag in trending_tags %}
|
||||
{% capture url %}/tags/{{ tag | downcase | url_encode }}/{% endcapture %}
|
||||
<a class="post-tag" href="{{ url | relative_url }}">{{ tag | replace: '-', ' ' }}</a>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
<div id="search-results" class="d-flex flex-wrap justify-content-center text-muted mt-3"></div>
|
||||
</div>
|
||||
|
|
|
@ -36,15 +36,12 @@ layout: compress
|
|||
<div id="main-wrapper">
|
||||
<div id="main">
|
||||
|
||||
{% capture _content %}
|
||||
{{ content }}
|
||||
{% endcapture %}
|
||||
|
||||
{% include fixlinenos.html %}
|
||||
{{ _content }}
|
||||
{% include fixlinenos.html content=content %}
|
||||
|
||||
{% include footer.html %}
|
||||
|
||||
</div>
|
||||
|
||||
{% include search-results.html %}
|
||||
|
||||
</div> <!-- #main-wrapper -->
|
||||
|
|
|
@ -58,9 +58,8 @@ layout: page
|
|||
</div>
|
||||
<div class="post-content">
|
||||
<p>
|
||||
{% assign _content = post.content %}
|
||||
{% include no-linenos.html %}
|
||||
{{ _content | markdownify | strip_html | truncate: 200 }}
|
||||
{% include no-linenos.html content=post.content %}
|
||||
{{ content | markdownify | strip_html | truncate: 200 }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -10,9 +10,8 @@ layout: compress
|
|||
"categories": "{{ post.categories | join: ', '}}",
|
||||
"tags": "{{ post.tags | join: ', ' }}",
|
||||
"date": "{{ post.date }}",
|
||||
{% assign _content = post.content %}
|
||||
{% include no-linenos.html %}
|
||||
"snippet": "{{ _content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}"
|
||||
{% include no-linenos.html content=post.content %}
|
||||
"snippet": "{{ content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}"
|
||||
}{% unless forloop.last %},{% endunless %}
|
||||
{% endfor %}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue