You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This modification to the chirpy theme will enable code blocks that specify a filename to optionally specify a URL that turns the rendered filename into a link that opens in a new tab/page if a link is external or same page if anchor/relative.
Then, copy the default stylesheet jekyll-theme-chirpy.scss to your project in the same location (/assets/css/jekyll-theme-chirpy.scss) and add the following block:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
This modification to the chirpy theme will enable code blocks that specify a filename to optionally specify a URL that turns the rendered filename into a link that opens in a new tab/page if a link is external or same page if anchor/relative.
Usage in chirpy markdown post:
Setup
Add
refactor-content.htmlto your project's_includesfolder.In the
<!-- Add header for code snippets -->section replace everything between{% if _left contains 'file="' %}and{% assign _new_content = _new_contentwith the following block:{% assign _label_link = '' %} {% if _left contains 'file="' %} {% assign _label_text = _left | split: 'file="' | last | split: '"' | first %} {% if _left contains 'link="' %} {% assign _label_link = _left | split: 'link="' | last | split: '"' | first %} {% endif %} {% assign _label_icon = 'far fa-file-code fa-fw' %} {% else %} {% assign _lang = _left | split: 'language-' | last | split: ' ' | first %} {% capture _label_text %}{% include language-alias.html language=_lang %}{% endcapture %} {% assign _label_icon = 'fas fa-code fa-fw small' %} {% endif %} {% if _label_link != '' %} {% assign _target = '_self' %} {% if _label_link contains 'http' %} {% assign _target = '_blank' %} {% endif %} {% capture _label %} <a target="{{ _target }}" href="{{ _label_link | strip }}" data-label-text="{{ _label_text | strip }}"><i class="{{ _label_icon }}"></i></a> {% endcapture %} {% else %} {% capture _label %} <span data-label-text="{{ _label_text | strip }}"><i class="{{ _label_icon }}"></i></span> {% endcapture %} {% endif %}Then, copy the default stylesheet
jekyll-theme-chirpy.scssto your project in the same location (/assets/css/jekyll-theme-chirpy.scss) and add the following block:Beta Was this translation helpful? Give feedback.
All reactions