Working table of contents. (Not how I want to work.)
This commit is contained in:
parent
9e40ef518d
commit
d4d183885d
13
content/components/toc.njk
Normal file
13
content/components/toc.njk
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% macro header(size, text, tocList) %}
|
||||
{% set tocList = (tocList.push([size, text]), tocList) %}
|
||||
<a name="{{ text | replace(" ", "-") }}"></a>
|
||||
<{{ size }}>
|
||||
{{ text }}
|
||||
</{{ size }}>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro generate(tocList) %}
|
||||
{% for size, text in tocList %}
|
||||
<a href="#{{ text | replace(" ", "-") }}" class="toc-{{ size }}">{{ text }}</a>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
18
content/pages/wiki/index.njk
Normal file
18
content/pages/wiki/index.njk
Normal file
|
@ -0,0 +1,18 @@
|
|||
{% extends "templates/article.njk" %}
|
||||
{% import "components/toc.njk" as toc with context %}
|
||||
|
||||
{% block body %}
|
||||
{{ super() }}
|
||||
|
||||
<div class="content">
|
||||
{{ toc.header("h1", "Testing", tocList) }}
|
||||
<p>Hello World!</p>
|
||||
|
||||
{{ toc.header("h1", "Development", tocList) }}
|
||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugiat optio earum unde reiciendis cumque, corrupti ipsum quia nemo deleniti officia quos laudantium error nobis at! Praesentium, officia vero! Ut, saepe vitae maiores velit ad quis! Cum quisquam ipsam nulla laudantium rerum sint eos magni, sunt porro fuga hic nihil obcaecati iure animi impedit repellendus nisi voluptas dolore, alias tenetur fugiat? Maiores quibusdam corporis recusandae unde eaque consectetur, officia harum optio fuga architecto beatae, reprehenderit aspernatur magnam debitis consequatur. Vero recusandae obcaecati harum minus facilis illo aliquid quis! Ipsam assumenda molestiae molestias quisquam illum nesciunt. Quam dolorem fuga saepe ratione labore tenetur in laborum, quae beatae quisquam, possimus doloremque iusto eum ex odit! Suscipit iste molestias nam cupiditate distinctio veniam sint laborum, culpa odio, voluptatem fugiat exercitationem, incidunt at.</p>
|
||||
</div>
|
||||
|
||||
<div class="toc">
|
||||
{{ toc.generate(tocList) }}
|
||||
</div>
|
||||
{% endblock %}
|
18
content/templates/article.njk
Normal file
18
content/templates/article.njk
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{% include "./defaultTags.njk" %}
|
||||
{% block head %}
|
||||
<title>{{ serverName }}</title>
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% set tocList = [] %}
|
||||
|
||||
<article>
|
||||
{% block body %}
|
||||
|
||||
{% endblock %}
|
||||
</article>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user