1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 05:41:31 +00:00

Add label icon to code snippet header

This commit is contained in:
Cotes Chung
2021-09-22 18:25:46 +08:00
parent 89b76dc2a0
commit 4ad0a76789
2 changed files with 33 additions and 16 deletions

View File

@@ -119,14 +119,20 @@
{% if _left contains 'file="' %}
{% assign _text = _left | split: 'file="' | last | split: '"' | first %}
{% assign _label_icon = 'far fa-file' %}
{% else %}
{% assign _text = _left | split: 'language-' | last | split: ' ' | first %}
{% assign _label_icon = 'fas fa-code small' %}
{% endif %}
{% capture _label %}
<span text-data="{{ _text }}"><i class="fa-fw {{ _label_icon }}"></i></span>
{% endcapture %}
{% assign _new_content = _new_content | append: _snippet
| append: '<div class="code-header" text-data="'
| append: _text
| append: '"><button aria-label="copy" data-original-title="'
| append: '<div class="code-header">'
| append: _label
| append: '<button aria-label="copy" data-original-title="'
| append: site.data.locales[lang].post.button.copy_code.succeed
| append: '"><i class="far fa-clone"></i></button></div>'
| append: '<div class="highlight"><code>'