From 8a9c0239b65be52f064526b273968c4e2969b758 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 2 Oct 2021 17:33:43 +0300 Subject: custom_{css,js}: support absolute URLs --- README.md | 2 +- _includes/common/footer.html | 8 +++++++- _includes/common/header.html | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d91d85d..2525072 100644 --- a/README.md +++ b/README.md @@ -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 @@ {% if page.custom_js %} {% for js in page.custom_js %} - + {% 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 %} + {% endfor %} {% endif %} 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 %} - + {% 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 %} + {% endfor %} {% endif %} -- cgit v1.2.3