You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mkbook/docs/04-structure/index.html

198 lines
9.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The mkbook Book | Structure</title>
<link rel="stylesheet" href="../style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="../favicon.ico" />
<meta property="og:title" content="The mkbook Book" />
<meta property="og:site_name" content="The mkbook Book" />
<meta property="og:type" content="book" />
<meta property="og:url" content="https://hamaluik.github.io/mkbook//04-structure/index.html" />
<meta property="book:author" content="Kenton Hamaluik" />
<meta property="book:release_date" content="2019-11-29T22:36:42.202445325+00:00" />
</head>
<body>
<nav class="big">
<header>
<h1><a href="../index.html">The mkbook Book</a></h1>
<h2>by Kenton Hamaluik</h2>
</header>
<ol>
<li>
<a href="../01-introduction/index.html">Introduction</a>
</li>
<li>
<a href="../02-markdown/index.html">Markdown</a>
<ol>
<li><a href="../02-markdown/01-commonmark.html">CommonMark</a></li>
<li><a href="../02-markdown/02-syntax-highlighting.html">Syntax Highlighting</a></li>
</ol>
</li>
<li>
<a href="../03-frontmatter/index.html">Front Matter</a>
</li>
<li>
<a href="../04-structure/index.html" class = "current">Structure</a>
</li>
<li>
<a href="../05-customization/index.html">Customization</a>
</li>
<li>
<a href="../06-how-it-works/index.html">How it Works</a>
</li>
</ol>
</nav>
<nav class="small">
<span>
<a href="../index.html" alt="Table of Contents">
<span class="icon">
<svg class="icon-list-ol">
<use xlink:href="../icons.svg#icon-list-ol">
</svg>
</span>
</a>
<a href="../03-frontmatter&#x2f;index.html" alt="Front Matter">
<span class="icon">
<svg class="icon-arrow-left">
<use xlink:href="../icons.svg#icon-arrow-left">
</svg>
</span>
</a>
</span>
<span class="title">Structure</span>
<span>
<span class="placeholder"></span>
<a href="../05-customization&#x2f;index.html" alt="Customization">
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="../icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</span>
</nav>
<article>
<h1><a href="#structure" aria-hidden="true" class="anchor" id="headerstructure"></a>Structure</h1>
<p><em>mkbook</em> follows a fairly simple directory structure for now, with a <code>README.md</code> file declaring the books metadata, and <code>.md</code> files defining each chapter of the book.</p>
<h2><a href="#readmemd" aria-hidden="true" class="anchor" id="headerreadmemd"></a><code>README.md</code></h2>
<p><em>mkbook</em> generally requires a <code>README.md</code> file to reside in your source directory. This file is responsible for defining the metadata associated with your book:</p>
<ul>
<li>The books title (<code>title</code>)</li>
<li>The books author (<code>author</code>)</li>
<li>The publication date (<code>pubdate</code>)</li>
<li>The canonical URL for the book (<code>url</code>)</li>
<li>A markdown-formatted description of the book</li>
</ul>
<p>If the <code>README.md</code> file or any of the entries are missing, default values will be used. The <code>README.md</code> file should be formatted as any other page, with the <code>title</code>, <code>author</code>, <code>pubdate</code>, and <code>url</code> specified in the frontmatter, and the book description the <em>Markdown</em> contents of the <code>README.md</code> file.</p>
<h3><a href="#sample" aria-hidden="true" class="anchor" id="headersample"></a>Sample</h3>
<pre style="background-color:#2d2d2d;">
<span style="background-color:#515151;color:#d3d0c8;">---
</span><span style="color:#d3d0c8;">title = &quot;The mkbook Book&quot;
</span><span style="color:#d3d0c8;">author = &quot;Kenton Hamaluik&quot;
</span><span style="color:#d3d0c8;">url = &quot;https://hamaluik.github.io/mkbook/&quot;
</span><span style="color:#6699cc;">---
</span><span style="color:#d3d0c8;">
</span><span style="font-style:italic;color:#cc99cc;">_mkbook_</span><span style="color:#d3d0c8;"> is my simpler alternative to </span><span style="color:#f99157;">[mdbook](https://crates.io/crates/mdbook)
</span><span style="color:#d3d0c8;">which is a great tool, but for which I really dislike some of the decisions they
</span><span style="color:#d3d0c8;">took, such as relying on javascript for highlighting and navigation, and
</span><span style="color:#d3d0c8;">including a lot of bells and whistles such as javascript-based search.
</span><span style="color:#d3d0c8;">
</span><span style="color:#d3d0c8;">This tool aims to work somewhat similarly to </span><span style="font-style:italic;color:#cc99cc;">_mdbook_</span><span style="color:#d3d0c8;">, but is generally intended
</span><span style="color:#d3d0c8;">to be a more minimal alternative that is customized more towards my needs and
</span><span style="color:#d3d0c8;">desires than anything else.
</span></pre>
<h3><a href="#default-values" aria-hidden="true" class="anchor" id="headerdefault-values"></a>Default Values</h3>
<dl><dt>
<p><code>title</code></p>
</dt>
<dd>
<p>“My Cool Book”</p>
</dd>
<dt>
<p><code>author</code></p>
</dt>
<dd>
<p>“Anonymous”</p>
</dd>
<dt>
<p><code>pubdate</code></p>
</dt>
<dd>
<p>The date the book was built from the command line, in UTC time</p>
</dd>
<dt>
<p><code>url</code></p>
</dt>
<dd>
<p>“”</p>
</dd>
<dt>
<p><code>description</code></p>
</dt>
<dd>
<p>“”</p>
</dd>
</dl>
<h2><a href="#assets" aria-hidden="true" class="anchor" id="headerassets"></a>Assets</h2>
<p>The current version of <em>mkbook</em> doesnt copy any assets into your book—it only parses <code>.md</code> files and generates <code>.html</code> files. So if you want to include images or other assets, youre on your own. Support for assets is planned for the next minor release.</p>
<h2><a href="#documents" aria-hidden="true" class="anchor" id="headerdocuments"></a>Documents</h2>
<p><em>mkbook</em> works on mostly a flat directory structure, however one level of sub-directories are supported in order to create sections within chapters. Files that dont end in a <code>.md</code> extension are completely ignored. Each <code>.md</code> file in the root source directly is its own chapter. To create chapters with sub-sections, create a sub-directory in the root directory and then create a <code>README.md</code> file, which will become the root of the chapter, with all <code>.md</code> files in the sub-directory becoming sections in the chapter. The <code>title</code> in the <code>README.md</code> files frontmatter will be used as the name of the chapter.</p>
<p>The order of the book is based on the alphabetical order of the file names (actually its based on Rusts <a href="https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html#impl-PartialOrd%3Cstr%3E">implementation of <code>PartialOrd</code> for str</a>). Thus, it is recommended to lay out your book chapters with manual numbering of the file names, as such:</p>
<pre style="background-color:#2d2d2d;">
<span style="color:#d3d0c8;">src/
</span><span style="color:#d3d0c8;">├── mkbook.toml
</span><span style="color:#d3d0c8;">├── 00-foreword.md
</span><span style="color:#d3d0c8;">├── 01-introduction.md
</span><span style="color:#d3d0c8;">└── 02-my-first-chapter
</span><span style="color:#d3d0c8;"> ├── index.md
</span><span style="color:#d3d0c8;"> ├── 01-my-first-section.md
</span><span style="color:#d3d0c8;"> ├── 02-my-second-section.md
</span><span style="color:#d3d0c8;"> └── etc...
</span></pre>
<p>An index and navigation will be automatically generated from these files, taking the information for each file from its front-matter.</p>
<div class="next-chapter">
<a href="../05-customization&#x2f;index.html">
<span>Next chapter: “Customization”</span>
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="../icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</div>
<footer><p>&copy; 2019 Kenton Hamaluik</p></footer>
</article>
</body>
</html>