mirror of
https://github.com/seigler/dash-website
synced 2025-07-27 07:16:10 +00:00
Relative links
Created a _include snippet base.html that can be used to create relative links to assets.
This commit is contained in:
parent
4419fa683e
commit
f371dd4cd3
25 changed files with 802 additions and 1512 deletions
18
_includes/base.html
Normal file
18
_includes/base.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!--
|
||||
Include this file in your templates so you can reference assets with relative urls
|
||||
{% include base.html %}
|
||||
example: href="{{ base }}/assets/css/style.css"
|
||||
-->
|
||||
{% assign base = '' %}
|
||||
{% assign depth = page.url | split: '/' | size | minus: 1 %}
|
||||
{% if depth == -1 %}{% assign base = '.' %}
|
||||
{% elsif depth == 1 %}{% assign base = '..' %}
|
||||
{% elsif depth == 2 %}{% assign base = '../..' %}
|
||||
{% elsif depth == 3 %}{% assign base = '../../..' %}
|
||||
{% elsif depth == 4 %}{% assign base = '../../../..' %}{% endif %}
|
||||
|
||||
{% if site.lang != "en" %}
|
||||
{% assign base = base | prepend: '../' %}
|
||||
{% endif %}
|
||||
|
||||
{% capture basenav %}{{ base }}{% if site.lang != "en" %}/{{ site.lang }}{% endif %}{% endcapture %}
|
Loading…
Add table
Add a link
Reference in a new issue