139 lines
6.8 KiB
HTML
139 lines
6.8 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>mdBook Documentation</title>
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<meta name="description" content="{% block description %}{% endblock %}">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<link rel="stylesheet" href="../../book.css" media="screen" title="no title" charset="utf-8">
|
|
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
|
|
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
|
|
<link rel="stylesheet" href="../../highlight.css" media="screen" title="no title" charset="utf-8">
|
|
</head>
|
|
<body>
|
|
|
|
<div id="sidebar" class="sidebar">
|
|
<ul class="chapter"><li><a href="../../README.html"><strong>1.</strong> mdBook</a></li><li><a href="../../cli/cli-tool.html"><strong>2.</strong> Command Line Tool</a></li><li><ul class="section"><li><a href="../../cli/init.html"><strong>2.1.</strong> init</a></li><li><a href="../../cli/build.html"><strong>2.2.</strong> build</a></li></ul><li><a href="../../format/format.html"><strong>3.</strong> Format</a></li><li><ul class="section"><li><a href="../../format/summary.html"><strong>3.1.</strong> SUMMARY.md</a></li><li><a href="../../format/config.html"><strong>3.2.</strong> Configuration</a></li><li><a href="../../format/theme/theme.html"><strong>3.3.</strong> Theme</a></li><li><ul class="section"><li><a href="../../format/theme/index-hbs.html"class="active"><strong>3.3.1.</strong> index.hbs</a></li><li><a href="../../format/theme/syntax-highlighting.html"><strong>3.3.2.</strong> Syntax highlighting</a></li></ul><li><strong>4.</strong> Rust Library</li></ul>
|
|
</div>
|
|
|
|
<div id="page-wrapper" class="page-wrapper">
|
|
|
|
<div class="page">
|
|
<div id="menu-bar" class="menu-bar">
|
|
<i id="sidebar-toggle" class="fa fa-bars left"></i>
|
|
<h1 class="menu-title">mdBook Documentation</h1>
|
|
</div>
|
|
|
|
<div id="content" class="content">
|
|
<h1>index.hbs</h1>
|
|
<p><code>index.hbs</code> is the handlebars template that is used to render the book.
|
|
The markdown files are processed to html and then injected in that template.</p>
|
|
<p>If you want to change the layout or style of your book, chances are that you will
|
|
have to modify this template a little bit. Here is what you need to know.</p>
|
|
<h2>Data</h2>
|
|
<p>A lot of data is exposed to the handlebars template with the "context".
|
|
In the handlebars template you can access this information by using</p>
|
|
<pre><code class="language-handlebars">{{name_of_property}}
|
|
</code></pre>
|
|
<p>Here is a list of the properties that are exposed:</p>
|
|
<ul>
|
|
<li>
|
|
<p><strong><em>language</em></strong> Language of the book in the form <code>en</code>. To use in <code class="language-html"><html lang="{{ language }}"></code> for example.
|
|
At the moment it is hardcoded.</p>
|
|
</li>
|
|
<li>
|
|
<p><strong><em>title</em></strong> Title of the book, as specified in <code>book.json</code></p>
|
|
</li>
|
|
<li>
|
|
<p><strong><em>path</em></strong> Relative path to the original markdown file from the source directory</p>
|
|
</li>
|
|
<li>
|
|
<p><strong><em>content</em></strong> This is the rendered markdown.</p>
|
|
</li>
|
|
<li>
|
|
<p><strong><em>path_to_root</em></strong> This is a path containing exclusively <code>../</code>'s that points to the root of the book from the current file.
|
|
Since the original directory structure is maintained, it is useful to prepend relative links with this <code>path_to_root</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><strong><em>chapters</em></strong> Is an array of dictionaries of the form</p>
|
|
<pre><code class="language-json">{"section": "1.2.1", "name": "name of this chapter", "path": "dir/markdown.md"}
|
|
</code></pre>
|
|
<p>containing all the chapters of the book. It is used for example to construct the table of contents (sidebar).</p>
|
|
</li>
|
|
</ul>
|
|
<h2>Handlebars Helpers</h2>
|
|
<p>In addition to the properties you can access, there are some handlebars helpers at your disposal.</p>
|
|
<ol>
|
|
<li>
|
|
<h3>toc</h3>
|
|
<p>The toc helper is used like this</p>
|
|
<pre><code class="language-handlebars">{{#toc}}{{/toc}}
|
|
</code></pre>
|
|
<p>and outputs something that looks like this, depending on the structure of your book</p>
|
|
<pre><code class="language-html"><ul class="chapter">
|
|
<li><a href="link/to/file.html">Some chapter</a></li>
|
|
<li>
|
|
<ul class="section">
|
|
<li><a href="link/to/other_file.html">Some other Chapter</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</code></pre>
|
|
<p>If you would like to make a toc with another structure, you have access to the chapters property containing all the data.
|
|
The only limitation at the moment is that you would have to do it with JavaScript instead of with a handlebars helper.</p>
|
|
<pre><code class="language-html"><script>
|
|
var chapters = {{chapters}};
|
|
// Processing here
|
|
</script>
|
|
</code></pre>
|
|
</li>
|
|
<li>
|
|
<h3>previous / next</h3>
|
|
<p>The previous and next helpers expose a <code>link</code> and <code>name</code> property to the previous and next chapters.</p>
|
|
<p>They are used like this</p>
|
|
<pre><code class="language-handlebars">{{#previous}}
|
|
<a href="{{link}}" class="nav-chapters previous">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
{{/previous}}
|
|
</code></pre>
|
|
<p>The inner html will only be rendered if the previous / next chapter exists.
|
|
Of course the inner html can be changed to your liking.</p>
|
|
</li>
|
|
</ol>
|
|
<hr />
|
|
<p>If you would like me to expose other properties or helpers, please <a href="https://github.com/azerupi/mdBook/issues">create a new issue</a>
|
|
and I will consider it.</p>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<!--
|
|
Doesn't seem to work: using JavaScript
|
|
alternative until I find a way to do it in the template
|
|
-->
|
|
|
|
<a href="../../format/theme/theme.html" class="nav-chapters previous">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<!-- -->
|
|
|
|
<!-- -->
|
|
|
|
<a href="../../format/theme/syntax-highlighting.html" class="nav-chapters next">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
<!-- -->
|
|
|
|
</div>
|
|
|
|
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
|
|
<script src="../../highlight.js"></script>
|
|
<script src="../../book.js"></script>
|
|
</body>
|
|
</html>
|