162 lines
4.9 KiB
Plaintext
162 lines
4.9 KiB
Plaintext
|
<style>
|
||
|
.grid {
|
||
|
display: grid;
|
||
|
grid-template-columns: 1fr 1fr;
|
||
|
}
|
||
|
.pageslist-demo .item {
|
||
|
border: 1px solid #eee;
|
||
|
border-radius: 4px;
|
||
|
overflow: hidden;
|
||
|
box-shadow: 0 0 5px #0001;
|
||
|
margin: 1em;
|
||
|
}
|
||
|
.pageslist-demo .item.span {
|
||
|
grid-column: 1 / span 2;
|
||
|
}
|
||
|
.pageslist-demo .desc {
|
||
|
background: #2EAE9B;
|
||
|
color: white;
|
||
|
font-size: .8em;
|
||
|
overflow: auto;
|
||
|
}
|
||
|
.pageslist-demo .desc p {
|
||
|
margin: 1em;
|
||
|
}
|
||
|
.pageslist-demo .desc code {
|
||
|
font-family: inherit;
|
||
|
border: none;
|
||
|
border-radius: 3px;
|
||
|
background: #456;
|
||
|
padding: .25em .5em;
|
||
|
margin: 1em;
|
||
|
display: block;
|
||
|
white-space: pre-wrap;
|
||
|
font-size: 1em;
|
||
|
}
|
||
|
.pageslist-demo ul {
|
||
|
list-style: none;
|
||
|
padding: 0;
|
||
|
margin: 1em;
|
||
|
}
|
||
|
.pageslist-demo ul ul {
|
||
|
padding-left: 1.5em;
|
||
|
margin: 0;
|
||
|
}
|
||
|
.pageslist-demo .is-active a {
|
||
|
font-style: italic;
|
||
|
}
|
||
|
.pageslist-demo .is-current a {
|
||
|
font-style: normal;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
.pageslist-demo a::before,
|
||
|
.pageslist-demo span::before {
|
||
|
content: "▹";
|
||
|
vertical-align: middle;
|
||
|
margin-right: .5em;
|
||
|
color: grey;
|
||
|
font: normal 1.2em normal mono;
|
||
|
}
|
||
|
.pageslist-demo .has-childs > a::before,
|
||
|
.pageslist-demo .has-childs > span::before {
|
||
|
content: "▾";
|
||
|
}
|
||
|
</style>
|
||
|
<div class="pageslist-demo">
|
||
|
<div class="grid">
|
||
|
<div class="item">
|
||
|
<div class="desc">
|
||
|
<p>Generate a flat navigation using the default page array.</p>
|
||
|
<code>{% raw %}{{ pages | navigation }}{% endraw %}</code>
|
||
|
</div>
|
||
|
{{ pages | navigation }}
|
||
|
</div>
|
||
|
<div class="item">
|
||
|
<div class="desc">
|
||
|
<p>Generate a nested navigation using the nested array.</p>
|
||
|
<code>{% raw %}{{ nested_pages | navigation }}{% endraw %}</code>
|
||
|
</div>
|
||
|
{{ nested_pages | navigation }}
|
||
|
</div>
|
||
|
<div class="item span">
|
||
|
<div class="desc">
|
||
|
<p>The html structure and the css classes allows styling current page, active parent pages, naked directories, getting pages by name, etc. to build any type of navigation : dropdown menus, single-lined breadcrumbs...
|
||
|
</p>
|
||
|
<code>{% raw %}.is-page, .is-directory, .is-current, .is-active, .has-childs ...{% endraw %}</code>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="item">
|
||
|
<div class="desc">
|
||
|
<p>Filtering pages paths with the <i>exclude</i> filter : </p>
|
||
|
<code>{% raw %}{{ nested_pages | exclude('PicoPagesList') | navigation }}{% endraw %}</code>
|
||
|
</div>
|
||
|
{{ nested_pages | exclude('PicoPagesList') | navigation }}
|
||
|
</div>
|
||
|
<div class="item">
|
||
|
<div class="desc">
|
||
|
<p>Filter the inner pages by using a trailing slash : </p>
|
||
|
<code>{% raw %}{{ nested_pages | exclude('PicoPagesList/') | navigation }}{% endraw %}</code>
|
||
|
</div>
|
||
|
{{ nested_pages | exclude('PicoPagesList/') | navigation }}
|
||
|
</div>
|
||
|
<div class="item">
|
||
|
<div class="desc">
|
||
|
<p>Filter all pages except the given ones with <i>only</i>, and chain filters : </p>
|
||
|
<code>{% raw %}{{ nested_pages | only('PicoPagesList') | exclude('PicoPagesList/sub/bar') | navigation }}{% endraw %}</code>
|
||
|
</div>
|
||
|
{{ nested_pages | only('PicoPagesList') | exclude('PicoPagesList/sub/bar') | navigation }}
|
||
|
</div>
|
||
|
<div class="item">
|
||
|
<div class="desc">
|
||
|
<p>Filters can be given multiple paths : </p>
|
||
|
<code>{% raw %}{{ nested_pages | only('PicoPagesList/sub', 'index') | navigation }}{% endraw %}</code>
|
||
|
</div>
|
||
|
{{ nested_pages | only('PicoPagesList/sub', 'index') | navigation }}
|
||
|
</div>
|
||
|
<div class="item span">
|
||
|
<div class="desc">
|
||
|
<p>Custom loop :</p>
|
||
|
<code>{% raw %}{% macro menu(items) %}
|
||
|
<ul>
|
||
|
{% for name,item in items %}
|
||
|
<li>
|
||
|
{% if item.url %}
|
||
|
<a href="{{ item.url }}">{{ item.title }}</a> : {{ item.description }}
|
||
|
{% else %}
|
||
|
<span>{{ name }}</span>
|
||
|
{% endif %}
|
||
|
{% if item._childs %}
|
||
|
{% import 'macros.twig' as macros %}
|
||
|
{{ macros.menu(item._childs) }}
|
||
|
{% endif %}
|
||
|
</li>
|
||
|
{% endfor %}
|
||
|
</ul>
|
||
|
{% endmacro %}{% endraw %}</code>
|
||
|
|
||
|
<code>{% raw %}{% import 'macros.twig' as macros %}
|
||
|
{{ macros.menu(nested_pages) }}{% endraw %}</code>
|
||
|
</div>
|
||
|
{% macro menu(items) %}
|
||
|
<ul>
|
||
|
{% for name,item in items %}
|
||
|
<li>
|
||
|
{% if item.url %}
|
||
|
<a href="{{ item.url }}">{{ item.title }}</a> : {{ item.description }}
|
||
|
{% else %}
|
||
|
<span>{{ name }}</span>
|
||
|
{% endif %}
|
||
|
{% if item._childs %}
|
||
|
{% import _self as macros %}
|
||
|
{{ macros.menu(item._childs) }}
|
||
|
{% endif %}
|
||
|
</li>
|
||
|
{% endfor %}
|
||
|
</ul>
|
||
|
{% endmacro %}
|
||
|
|
||
|
{% import _self as macros %}
|
||
|
{{ macros.menu(nested_pages) }}
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|