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: ""
values:
layout: sidebar
-
scope:
path: "*"
values:
root: "."
-
scope:
path: "*/*"
values:
root: ".."
-
scope:
path: "*/*/*"
values:
root: "../.."
collections_dir: docs
collections:

View File

@ -5,28 +5,28 @@
<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 %}
{% 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 %}
{% endif %}
{% if 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 %}
{% endif %}
{% if 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 %}
{% endif %}
{% if page.js %}
{% for js in page.js %}
<script src="{{ js | prepend: site.baseurl | replace: '//', '/' }}"></script>
<script src="{% include link.html url=js %}"></script>
{% endfor %}
{% 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 %}
<body>
<p>baseurl: {{ site.baseurl }} </p>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
@ -27,19 +26,20 @@ common-js:
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</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 id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
{% for link in site.data.navbar %}
<li>
<a href="{{ link[1] | prepend: site.baseurl | replace: '//', '/' }}">{{ link[0] }}</a>
<a href="{% include link.html url=link.last %}">{{ link.first }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
</nav>
<p>debug path:{{ page.path }}</p>
{{ content }}
<hr/>
<footer class="container">

2
doc.md
View File

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