summaryrefslogtreecommitdiff
path: root/spec/_layouts/default.yml
diff options
context:
space:
mode:
authorAntoine Gourlay <antoine@gourlay.fr>2014-09-22 14:29:32 +0200
committerAntoine Gourlay <antoine@gourlay.fr>2014-09-22 16:50:34 +0200
commit3a72a9d1109e995b9c4de70f260ac3b5ac8f73b9 (patch)
treec97e3192030f7896d3eb56ea42166fe07a4b5f4b /spec/_layouts/default.yml
parent79564697351c439c8c79ecd50c802defda5bfa4e (diff)
downloadscala-3a72a9d1109e995b9c4de70f260ac3b5ac8f73b9.tar.gz
scala-3a72a9d1109e995b9c4de70f260ac3b5ac8f73b9.tar.bz2
scala-3a72a9d1109e995b9c4de70f260ac3b5ac8f73b9.zip
spec: generated TOC with linkable headers
This adds a table of contents to the spec, with a way to get the link of a header on hover (like on GitHub) and a "return to top" small icon at the end of each section. Jekyll generates the H1-level table of contents, and then the current one is expended using jQuery all the way down to H5 titles. Examples and H6 headers are ignored. GitHub's (MIT licensed) octicons are used for nice "link" and "up" icons.
Diffstat (limited to 'spec/_layouts/default.yml')
-rw-r--r--spec/_layouts/default.yml32
1 files changed, 30 insertions, 2 deletions
diff --git a/spec/_layouts/default.yml b/spec/_layouts/default.yml
index f78232f461..fbbab3a1a0 100644
--- a/spec/_layouts/default.yml
+++ b/spec/_layouts/default.yml
@@ -14,7 +14,9 @@
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.2/styles/default.min.css">
+ <link rel="stylesheet" href="public/octicons/octicons.css">
<script src="public/highlight/highlight.pack.js"></script>
+ <script src="public/scripts/navigation.js"></script>
<!-- need to use include to see value of page.chapter variable -->
<style type="text/css">
@@ -39,6 +41,11 @@
hljs.initHighlighting();
$("pre nobr").addClass("fixws");
})
+
+ // and finally TOC generation
+ $(document).ready(function() {
+ $('.toc').navigation();
+ })
</script>
<link rel="stylesheet" type="text/css" href="public/stylesheets/screen.css">
@@ -46,8 +53,29 @@
</head>
<body>
-
+<div id="container">
+<div id="navigation">
+<ol>
+ {% assign sorted_pages = site.pages | sort:"name" %}
+ {% for post in sorted_pages %}
+ {% if post.chapter >= 0 %}
+ {% if page.url == post.url %}
+ <li class="active-page">
+ <a href="{{site.baseurl}}{{ post.url }}"> {{ post.title }}</a>
+ <div class="toc"></div>
+ </li>
+ {% else %}
+ <li>
+ <a href="{{site.baseurl}}{{ post.url }}"> {{ post.title }}</a>
+ </li>
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+</ol>
+</div>
+<div id="content-container">
{{ content }}
-
+</div>
+</div>
</body>
</html>