From 7b8f2865857b528b1f2b1e8e30fec2e6eafd8469 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 22 Mar 2022 12:32:10 +0300 Subject: get rid of custom_{css,js} in favour of a generic mechanism --- _includes/common/footer.html | 30 +++++++++++++++++++++--------- _includes/common/header.html | 31 +++++++++++++++++++------------ 2 files changed, 40 insertions(+), 21 deletions(-) (limited to '_includes') diff --git a/_includes/common/footer.html b/_includes/common/footer.html index 6fe7d65..e8fd04b 100644 --- a/_includes/common/footer.html +++ b/_includes/common/footer.html @@ -48,16 +48,28 @@ - {% 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 %} + + {% assign scripts = '' | split: '' %} + {% if site.settings.scripts %} + {% assign scripts = scripts | concat: site.settings.scripts %} + {% endif %} + {% if page.scripts %} + {% assign scripts = scripts | concat: page.scripts %} + {% endif %} + + {% for script in scripts %} + {% assign abs_check = script.src | downcase | split: '//' %} + {% if abs_check[0] == 'http:' or abs_check[0] == 'https:' or abs_check[0] == '' %} + {% assign url = script.src %} + {% else %} + {% assign abs_check = script.src | slice: 0 %} + {% if abs_check == '/' %} + {% assign url = script.src %} {% else %} - {% assign url = '/assets/js/' | relative_url | append: js %} + {% assign url = script.src | relative_url %} {% endif %} - - {% endfor %} - {% endif %} + {% endif %} + + {% endfor %} diff --git a/_includes/common/header.html b/_includes/common/header.html index 6798ec1..82c3801 100644 --- a/_includes/common/header.html +++ b/_includes/common/header.html @@ -47,20 +47,27 @@ - {% 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 %} + {% assign links = '' | split: '' %} + {% if site.settings.links %} + {% assign links = links | concat: site.settings.links %} + {% endif %} + {% if page.links %} + {% assign links = links | concat: page.links %} {% endif %} - {% for link in site.settings.links %} - + {% for link in links %} + {% assign abs_check = link.href | downcase | split: '//' %} + {% if abs_check[0] == 'http:' or abs_check[0] == 'https:' or abs_check[0] == '' %} + {% assign url = link.href %} + {% else %} + {% assign abs_check = link.href | slice: 0 %} + {% if abs_check == '/' %} + {% assign url = link.href %} + {% else %} + {% assign url = link.href | relative_url %} + {% endif %} + {% endif %} + {% endfor %} {% if site.settings.ga_tag %} -- cgit v1.2.3