Use page.root for relative links

This commit is contained in:
Adam Schmideg
2019-03-21 15:33:28 +01:00
parent ad91ddbe37
commit aa9c2d2b00
5 changed files with 25 additions and 10 deletions

View File

@ -15,6 +15,21 @@ defaults:
path: "" path: ""
values: values:
layout: sidebar layout: sidebar
-
scope:
path: "*"
values:
root: "."
-
scope:
path: "*/*"
values:
root: ".."
-
scope:
path: "*/*/*"
values:
root: "../.."
collections_dir: docs collections_dir: docs
collections: collections:

View File

@ -5,28 +5,28 @@
<title>{% if page.title %}{{ page.title }} | {% endif %}Go Ethereum</title> <title>{% if page.title %}{{ page.title }} | {% endif %}Go Ethereum</title>
<link rel="icon" type="image/png" href="{{ site.favicon | prepend: site.baseurl | replace: '//', '/'}}" /> <link rel="icon" type="image/png" href="{% include link.html url=site.favicon %}" />
{% if layout.common-css %} {% if layout.common-css %}
{% for css in layout.common-css %} {% for css in layout.common-css %}
<link rel="stylesheet" href="{{ css | prepend: site.baseurl | replace: '//', '/' }}" /> <link rel="stylesheet" href="{% include link.html url=css %}"" />
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if page.css %} {% if page.css %}
{% for css in page.css %} {% for css in page.css %}
<link rel="stylesheet" href="{{ css | prepend: site.baseurl | replace: '//', '/' }}" /> <link rel="stylesheet" href="{% include link.html url=css %}"" />
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if layout.common-js %} {% if layout.common-js %}
{% for js in layout.common-js %} {% for js in layout.common-js %}
<script src="{{ js | prepend: site.baseurl | replace: '//', '/' }}"></script> <script src="{% include link.html url=js %}"></script>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if page.js %} {% if page.js %}
{% for js in page.js %} {% for js in page.js %}
<script src="{{ js | prepend: site.baseurl | replace: '//', '/' }}"></script> <script src="{% include link.html url=js %}"></script>
{% endfor %} {% endfor %}
{% endif %} {% endif %}

View File

@ -1 +1 @@
{{ include.url | remove: ".html" | prepend: site.baseurl | replace: '//', '/' }} {{ include.url | remove: ".html" | prepend: page.root | replace: '//', '/' }}

View File

@ -17,7 +17,6 @@ common-js:
{% include head.html %} {% include head.html %}
<body> <body>
<p>baseurl: {{ site.baseurl }} </p>
<nav class="navbar navbar-default navbar-fixed-top"> <nav class="navbar navbar-default navbar-fixed-top">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
@ -27,19 +26,20 @@ common-js:
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="{{ site.url }}{{ site.baseurl }}">Go Ethereum</a> <a class="navbar-brand" href="{{ page.root }}/">Go Ethereum</a>
</div> </div>
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
{% for link in site.data.navbar %} {% for link in site.data.navbar %}
<li> <li>
<a href="{{ link[1] | prepend: site.baseurl | replace: '//', '/' }}">{{ link[0] }}</a> <a href="{% include link.html url=link.last %}">{{ link.first }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
</div> </div>
</nav> </nav>
<p>debug path:{{ page.path }}</p>
{{ content }} {{ content }}
<hr/> <hr/>
<footer class="container"> <footer class="container">

2
doc.md
View File

@ -1,7 +1,7 @@
--- ---
title: Other documents title: Other documents
root: ..
--- ---
{% for p in site.doc %} {% for p in site.doc %}
* [{{ p.title }}]({% include link.html url=p.url %}) * [{{ p.title }}]({% include link.html url=p.url %})
{% endfor %} {% endfor %}