Use macro for URLs that may be relative to site root
There are multiple places in the theme where URL value may be either relative to site root or pointing to a third-party resource. Separating the handler logic into a macro makes sense. Now BOOTSTRAP_CSS may contain paths relative to site root - that allows users to apply custom Boostwatch themes without depending on third party resources (custom theme may be included as static file and referenced via relative path).main
parent
c66ac71cf7
commit
5251f12a56
|
@ -1,3 +1,12 @@
|
||||||
|
{%- macro url(destination) -%}
|
||||||
|
{%- if destination|lower|truncate(4, True, '') == 'http' or not destination -%}
|
||||||
|
{{ destination }}
|
||||||
|
{%- elif destination|first == '/' -%}
|
||||||
|
{{ SITEURL + destination }}
|
||||||
|
{%- else -%}
|
||||||
|
{{ SITEURL + '/' + destination }}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endmacro -%}
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="{{ DEFAULT_LANG }}">
|
<html lang="{{ DEFAULT_LANG }}">
|
||||||
|
|
||||||
|
@ -17,16 +26,12 @@
|
||||||
<meta name="theme-color" content="#333333">
|
<meta name="theme-color" content="#333333">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{ BOOTSTRAP_CSS or SITEURL + '/theme/css/bootstrap.min.css'}}">
|
<link rel="stylesheet" href="{{ url(BOOTSTRAP_CSS or '/theme/css/bootstrap.min.css') }}">
|
||||||
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/font-awesome.min.css">
|
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/font-awesome.min.css">
|
||||||
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/pygments/{{ PYGMENTS_STYLE|default('default') }}.min.css">
|
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/pygments/{{ PYGMENTS_STYLE|default('default') }}.min.css">
|
||||||
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/theme.css">
|
<link rel="stylesheet" href="{{ SITEURL }}/theme/css/theme.css">
|
||||||
{% for stylesheet in THEME_CSS_OVERRIDES or () %}
|
{% for stylesheet in THEME_CSS_OVERRIDES or () %}
|
||||||
{% if stylesheet|lower|truncate(4, True, '') == 'http' %}
|
<link rel="stylesheet" href="{{ url(stylesheet) }}">
|
||||||
<link rel="stylesheet" href="{{ stylesheet }}">
|
|
||||||
{% else %}
|
|
||||||
<link rel="stylesheet" href="{{ SITEURL + '/' + stylesheet }}">
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% include 'include/xml_feeds.html' %}
|
{% include 'include/xml_feeds.html' %}
|
||||||
|
|
Loading…
Reference in New Issue