use gh-pages for serving the demo book

master
Kenton Hamaluik 5 years ago
parent 7125ba3098
commit 6672eecfe9

@ -4,4 +4,4 @@
This tool aims to work somewhat similarly to _mkbook_, but is generally intended to be a more minimal alternative that is customized more towards my needs and desires than anything else.
Still very WIP, but it can convert `.md` files into fancy-looking `.html` files, demo it by running: `cargo run -- build demo` and then serving the `demo/book` directory.
Still very WIP, but it can convert `.md` files into fancy-looking `.html` files, demo it by building the `mkbook` book by running: `cargo run -- build -i docs-src -o docs` and then serving the `docs` directory. Alternatively, view these generated docs [here](https://hamaluik.github.io/mkbook/01-introduction.html).

1
demo/.gitignore vendored

@ -1 +0,0 @@
book/

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Introduction</title>
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<nav class="big">
<a href="01-introduction.html" class = "current">Introduction</a>
<a href="02-markdown.html">Markdown</a>
<a href="03-frontmatter.html">Front Matter</a>
<a href="04-structure.html">Structure</a>
</nav>
<nav class="small">
<span class="placeholder"></span>
<span class="title">Introduction</span>
<a href="02-markdown.html">
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</nav>
<article></article>
</body>
</html>

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Markdown</title>
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<nav class="big">
<a href="01-introduction.html">Introduction</a>
<a href="02-markdown.html" class = "current">Markdown</a>
<a href="03-frontmatter.html">Front Matter</a>
<a href="04-structure.html">Structure</a>
</nav>
<nav class="small">
<a href="01-introduction.html">
<span class="icon">
<svg class="icon-arrow-left">
<use xlink:href="icons.svg#icon-arrow-left">
</svg>
</span>
</a>
<span class="title">Markdown</span>
<a href="03-frontmatter.html">
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</nav>
<article></article>
</body>
</html>

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Front Matter</title>
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<nav class="big">
<a href="01-introduction.html">Introduction</a>
<a href="02-markdown.html">Markdown</a>
<a href="03-frontmatter.html" class = "current">Front Matter</a>
<a href="04-structure.html">Structure</a>
</nav>
<nav class="small">
<a href="02-markdown.html">
<span class="icon">
<svg class="icon-arrow-left">
<use xlink:href="icons.svg#icon-arrow-left">
</svg>
</span>
</a>
<span class="title">Front Matter</span>
<a href="04-structure.html">
<span class="icon">
<svg class="icon-arrow-right">
<use xlink:href="icons.svg#icon-arrow-right">
</svg>
</span>
</a>
</nav>
<article><h1><a href="#front-matter" aria-hidden="true" class="anchor" id="headerfront-matter"></a>Front Matter</h1>
<p>Each <code>.md</code> file can optionally contain a header with metadata describing the document. If the header isnt present, default values will be used which may look ugly.</p>
<p>To insert a header into a <code>.md</code> file, insert three dashes (<code>---</code>), followed by a new-line, followed by the front matter contents, followed by a newline, then another three dashes and a new-line. The metadata is in the <a href="https://github.com/toml-lang/toml">TOML</a> format, so for example the front-matter (and first line) for this file looks like:</p>
<pre style="background-color:#2d2d2d;">
<span style="background-color:#515151;color:#d3d0c8;">---
</span><span style="color:#d3d0c8;">title = &quot;Front Matter&quot;
</span><span style="color:#6699cc;">---
</span><span style="color:#d3d0c8;">
</span><span style="color:#6699cc;"># Front Matter
</span><span style="color:#d3d0c8;">
</span><span style="color:#d3d0c8;">Each </span><span style="color:#99cc99;">`.md`</span><span style="color:#d3d0c8;"> file can optionally contain a header with metadata describing the document. If the header isn&#39;t present, default values will be used which may look ugly.
</span></pre>
<h2><a href="#supported-keys" aria-hidden="true" class="anchor" id="headersupported-keys"></a>Supported Keys</h2>
<p>The list of supported keys is subject to change, but for now it is as follows:</p>
<dl><dt>
<p>title</p>
</dt>
<dd>
<p>A human-readable title for the document</p>
</dd>
</dl>
</article>
</body>
</html>

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Structure</title>
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<nav class="big">
<a href="01-introduction.html">Introduction</a>
<a href="02-markdown.html">Markdown</a>
<a href="03-frontmatter.html">Front Matter</a>
<a href="04-structure.html" class = "current">Structure</a>
</nav>
<nav class="small">
<a href="03-frontmatter.html">
<span class="icon">
<svg class="icon-arrow-left">
<use xlink:href="icons.svg#icon-arrow-left">
</svg>
</span>
</a>
<span class="title">Structure</span>
<span class="placeholder"></span>
</nav>
<article></article>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@ -0,0 +1,12 @@
<svg aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-arrow-left" viewBox="0 0 448 512">
<title>arrow-left</title>
<path fill="currentColor" d="M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z"></path>
</symbol>
<symbol id="icon-arrow-right" viewBox="0 0 448 512">
<title>arrow-right</title>
<path fill="currentColor" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path>
</symbol>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 963 B

@ -0,0 +1 @@
@import url("https://fonts.googleapis.com/css?family=Crimson+Pro|Poppins:700|Source+Code+Pro&display=swap");body{margin:0;line-height:1.5;font-size:14pt;color:#222222;background:#eeeeee;padding:0;font-family:"Crimson Pro","Georgia",Georgia,"Times New Roman",Times,serif}h1,h2,h3{margin-top:0;line-height:1.2;font-family:"Poppins","Franklin Gothic Medium","Arial Narrow",Arial,sans-serif}a{color:#222222;text-decoration:underline}a:hover{color:#8a2888;text-decoration:none}figure{display:block;text-align:center;overflow-x:auto}figure img,figure video{max-width:100%}figure figcaption{display:block;font-size:0.75em;text-align:center}code{margin:0 2px;padding:0 2px;border:1px solid #4c566a;border-radius:3px;word-break:break-all;font-family:"Source Code Pro","Courier New",Courier,monospace;font-size:0.75em}pre{overflow-x:auto;font-family:"Source Code Pro","Courier New",Courier,monospace;padding:0}dl{display:grid;grid-template-columns:auto 1fr}dl dt{font-weight:700;margin:0;padding:0.5em;border-right:1px solid #dddddd}dl dd{margin:0;padding:0.5em}dl dt p,dl dd p{margin:0}html,body{width:100%;min-height:100vh}body{display:grid;grid-template-columns:auto 1fr;grid-template-rows:1fr;justify-items:stretch;align-items:stretch}body nav.big{background:#2c2c38;padding:1em;display:flex;flex-direction:column}body nav.big a{width:100%;font-size:1.5em;text-decoration:none;font-family:"Poppins","Franklin Gothic Medium","Arial Narrow",Arial,sans-serif;margin:0 0 0.25em 0;color:#5babd1}body nav.big a:hover{color:#cf5ccd}body nav.big a.current{color:#cf5ccd}body nav.big a.current:hover{color:#fefefe}body nav.small{display:none;width:100%;align-items:center;justify-content:space-between;background:#2c2c38;padding:0}body nav.small>*{margin:0.5em}body nav.small a{text-decoration:none;font-family:"Poppins","Franklin Gothic Medium","Arial Narrow",Arial,sans-serif;color:#5babd1}body nav.small a:hover{color:#cf5ccd}body nav.small span.title{text-decoration:none;font-family:"Poppins","Franklin Gothic Medium","Arial Narrow",Arial,sans-serif;color:#fefefe}body nav.small span.placeholder{width:1em;height:1em}body article{padding:1em 2em 0 2em;max-width:38em;min-width:0;min-height:0}body article>*{max-width:100%}@media screen and (max-width: 768px){body{grid-template-columns:1fr;grid-template-rows:auto 1fr}body nav.big{display:none}body nav.small{display:flex}body article{padding:1em 0.5em 0 0.5em}}span.icon{display:flex;align-items:center}[class^="icon-"],[class*=" icon-"]{display:inline-block;width:1em;height:1em;stroke-width:0;stroke:currentColor;fill:currentColor}.icon-arrow-left{width:0.875em}.icon-arrow-right{width:0.875em}@media (prefers-color-scheme: dark){body{background-color:#222222;color:#eeeeee}a{color:#eeeeee}a:hover{color:#5babd1}nav{background:#18181d}img{filter:grayscale(30%)}}@media print{body{background:#ffffff;color:#000000}a{color:#000000;text-decoration:underline}h2,h3{break-after:avoid-page}figure{break-inside:avoid}p{orphans:2;widows:2}*{overflow:hidden}nav{display:none}body{display:block}}

@ -16,8 +16,17 @@ pub fn build_cli() -> App<'static, 'static> {
)
.subcommand(SubCommand::with_name("build")
.about("build the book")
.arg(Arg::with_name("directory")
.help("an optional directory to build the book in (defaults to the CWD)")
.arg(Arg::with_name("in")
.short("i")
.long("in")
.default_value("src")
.help("an optional directory to take the book sources from")
)
.arg(Arg::with_name("out")
.short("o")
.long("out")
.default_value("book")
.help("an optional directory to render the contents into")
)
)
}

@ -177,15 +177,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
unimplemented!()
}
else if let Some(submatches) = matches.subcommand_matches("build") {
let prefix = if let Some(directory) = submatches.value_of("directory") {
PathBuf::from(directory)
}
else {
PathBuf::from(".")
};
let src = submatches.value_of("in").expect("in value");
let dest = submatches.value_of("out").expect("out value");
let src = prefix.join("src");
let dest = prefix.join("book");
let src = PathBuf::from(src);
let dest = PathBuf::from(dest);
std::fs::create_dir_all(&dest)?;
// load all our chapters
@ -202,7 +198,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let (front, _) = extract_frontmatter(&contents)?;
let front = front.unwrap_or_default().into_front(name);
chapters.push(models::chapter::Chapter {
url: format!("/{}.html", name),
url: format!("{}.html", name),
title: front.title,
});
}
@ -226,7 +222,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let (front, contents) = extract_frontmatter(&contents)?;
let front = front.unwrap_or_default().into_front(name);
let contents = format_markdown(&contents)?;
format_page(front, &chapters, &format!("/{}.html", name), &contents, outfile)?;
format_page(front, &chapters, &format!("{}.html", name), &contents, outfile)?;
println!("Rendered `{}` into `{}`", path.display(), out.display());
}

@ -4,8 +4,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title }}</title>
<link rel="stylesheet" href="/style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<nav class="big">

Loading…
Cancel
Save