diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-10-02 17:33:43 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-10-02 17:40:29 +0300 |
commit | 8a9c0239b65be52f064526b273968c4e2969b758 (patch) | |
tree | 6858169e8742277811a14786a9e18ee9733a5dc7 | |
parent | README: update (diff) | |
download | jekyll-theme-8a9c0239b65be52f064526b273968c4e2969b758.tar.gz jekyll-theme-8a9c0239b65be52f064526b273968c4e2969b758.zip |
custom_{css,js}: support absolute URLs
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | _includes/common/footer.html | 8 | ||||
-rw-r--r-- | _includes/common/header.html | 8 |
3 files changed, 15 insertions, 3 deletions
@@ -149,7 +149,7 @@ See [this post][mathjax post] for a usage example. Include custom CSS stylesheets in the header & custom JavaScript files in the footer by specifying the `page.custom_css` and `page.custom_js` arrays. They will be picked up from the root "assets/css" and "assets/js" directories -respectively. +respectively (unless the URL is absolute). History ------- diff --git a/_includes/common/footer.html b/_includes/common/footer.html index 0e2aecf..0d7a2a0 100644 --- a/_includes/common/footer.html +++ b/_includes/common/footer.html @@ -23,7 +23,13 @@ <script src="{{ '/assets/bootstrap/js/bootstrap.min.js' | relative_url }}"></script> {% if page.custom_js %} {% for js in page.custom_js %} - <script src="{{ '/assets/js/' | relative_url }}{{ js }}"></script> + {% assign abs_check = js | downcase | split: '//' %} + {% if abs_check[0] == 'http:' or abs_check[0] == 'https:' or abs_check[0] == blank %} + {% assign url = js %} + {% else %} + {% assign url = '/assets/js/' | relative_url | append: js %} + {% endif %} + <script src="{{ url }}"></script> {% endfor %} {% endif %} </body> diff --git a/_includes/common/header.html b/_includes/common/header.html index 464e42a..f905e37 100644 --- a/_includes/common/header.html +++ b/_includes/common/header.html @@ -23,7 +23,13 @@ {% if page.custom_css %} {% for css in page.custom_css %} - <link rel="stylesheet" href="{{ '/assets/css/' | relative_url }}{{ css }}"> + {% assign abs_check = css | downcase | split: '//' %} + {% if abs_check[0] == 'http:' or abs_check[0] == 'https:' or abs_check[0] == blank %} + {% assign url = css %} + {% else %} + {% assign url = '/assets/css/' | relative_url | append: css %} + {% endif %} + <link rel="stylesheet" href="{{ url }}"> {% endfor %} {% endif %} </head> |