Created
July 29, 2016 18:13
-
-
Save Jetroid/bd71e5bbc2de763d0973e706efc91d7c to your computer and use it in GitHub Desktop.
A hacky Liquid script to allow page-specific stylesheets using Yaml Front Matter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
--- | |
{% assign delim = "|" %} | |
{% assign had_elements = "" %} | |
<!-- Custom Stylesheets - use custom_css in YAML front matter !--> | |
{% if page.custom_css %} | |
{% for stylesheet in page.custom_css %} | |
{% capture had_elements %}{{ had_elements | join: delim }}{{ delim }}{{ stylesheet }}{% endcapture %} | |
{% assign had_elements = had_elements | split: delim %} | |
<link rel="stylesheet" href="/assets/css/{{ stylesheet }}.css" type="text/css"> | |
{% endfor %} | |
{% endif %} | |
{% if layout.custom_css %} | |
{% for stylesheet in layout.custom_css %} | |
{% if had_elements contains stylesheet %}{% else %} | |
<link rel="stylesheet" href="/assets/css/{{ stylesheet }}.css" type="text/css"> | |
{% endif %} | |
{% endfor %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment