mirror of https://github.com/hamaluik/mkbook
generating index, added meta tags, added book.toml file, styling improvements
parent
2aedd7aa8a
commit
c4f87aedd8
@ -1,7 +1,7 @@
|
||||
# mkbook
|
||||
|
||||
**mkbook** is my simpler alternative to [mdbook](https://crates.io/crates/mdbook) which is a great tool, but for which I really dislike some of the decisions they took, such as relying on javascript for highlighting and navigation, and including a lot of bells and whistles such as javascript-based search.
|
||||
_mkbook_ is my simpler alternative to [mdbook](https://crates.io/crates/mdbook) which is a great tool, but for which I really dislike some of the decisions they took, such as relying on javascript for highlighting and navigation, and including a lot of bells and whistles such as javascript-based search.
|
||||
|
||||
This tool aims to work somewhat similarly to _mdbook_, 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 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).
|
||||
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/).
|
||||
|
Before Width: | Height: | Size: 963 B After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,8 @@
|
||||
title = "The mkbook Book"
|
||||
author = "Kenton Hamaluik"
|
||||
url = "https://hamaluik.github.io/mkbook/"
|
||||
description = """
|
||||
_mkbook_ is my simpler alternative to [mdbook](https://crates.io/crates/mdbook) which is a great tool, but for which I really dislike some of the decisions they took, such as relying on javascript for highlighting and navigation, and including a lot of bells and whistles such as javascript-based search.
|
||||
|
||||
This tool aims to work somewhat similarly to _mdbook_, but is generally intended to be a more minimal alternative that is customized more towards my needs and desires than anything else.
|
||||
"""
|
Before Width: | Height: | Size: 963 B After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>The mkbook Book</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/" />
|
||||
<meta property="og:description" content="<p><em>mkbook</em> is my simpler alternative to <a href="https://crates.io/crates/mdbook">mdbook</a> which is a great tool, but for which I really dislike some of the decisions they took, such as relying on javascript for highlighting and navigation, and including a lot of bells and whistles such as javascript-based search.</p>
|
||||
<p>This tool aims to work somewhat similarly to <em>mdbook</em>, but is generally intended to be a more minimal alternative that is customized more towards my needs and desires than anything else.</p>
|
||||
" />
|
||||
<meta property="book:author" content="Kenton Hamaluik" />
|
||||
<meta property="book:release_date" content="2019-11-28T18:22:59.188707583+00:00" />
|
||||
</head>
|
||||
<body class="toc">
|
||||
<header>
|
||||
<h1>The mkbook Book</h1>
|
||||
<h2>by Kenton Hamaluik</h2>
|
||||
<time datetime="2019-11-28T18:22:59.188707583+00:00">Nov 28, 2019</time>
|
||||
</header>
|
||||
<article>
|
||||
<p><em>mkbook</em> is my simpler alternative to <a href="https://crates.io/crates/mdbook">mdbook</a> which is a great tool, but for which I really dislike some of the decisions they took, such as relying on javascript for highlighting and navigation, and including a lot of bells and whistles such as javascript-based search.</p>
|
||||
<p>This tool aims to work somewhat similarly to <em>mdbook</em>, but is generally intended to be a more minimal alternative that is customized more towards my needs and desires than anything else.</p>
|
||||
|
||||
</article>
|
||||
<nav>
|
||||
<h1>Table of Contents</h1>
|
||||
<ol>
|
||||
|
||||
<li><a href="01-introduction.html">Introduction</a></li>
|
||||
|
||||
<li><a href="02-markdown.html">Markdown</a></li>
|
||||
|
||||
<li><a href="03-frontmatter.html">Front Matter</a></li>
|
||||
|
||||
<li><a href="04-structure.html">Structure</a></li>
|
||||
|
||||
</ol>
|
||||
</nav>
|
||||
<footer><p>© 2019 Kenton Hamaluik</p></footer>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,13 @@
|
||||
use chrono::prelude::*;
|
||||
|
||||
pub fn rfc3339_utc(d: &DateTime<Utc>) -> askama::Result<String> {
|
||||
Ok(d.to_rfc3339())
|
||||
}
|
||||
|
||||
pub fn human_date(d: &DateTime<Utc>) -> askama::Result<String> {
|
||||
Ok(d.format("%b %e, %Y").to_string())
|
||||
}
|
||||
|
||||
pub fn year(d: &DateTime<Utc>) -> askama::Result<String> {
|
||||
Ok(d.format("%Y").to_string())
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
pub mod book;
|
||||
pub mod chapter;
|
||||
pub mod frontmatter;
|
||||
|
@ -0,0 +1,46 @@
|
||||
use serde::Deserialize;
|
||||
use chrono::prelude::*;
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
pub struct ParsedBook {
|
||||
pub title: Option<String>,
|
||||
pub author: Option<String>,
|
||||
pub pubdate: Option<toml::value::Datetime>,
|
||||
pub url: Option<String>,
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
pub struct Book {
|
||||
pub title: String,
|
||||
pub author: String,
|
||||
pub pubdate: DateTime<Utc>,
|
||||
pub url: String,
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
impl From<ParsedBook> for Book {
|
||||
fn from(pb: ParsedBook) -> Book {
|
||||
Book {
|
||||
title: match pb.title {
|
||||
Some(title) => title.clone(),
|
||||
None => "My Cool Book".to_owned(),
|
||||
},
|
||||
author: match pb.author {
|
||||
Some(author) => author.clone(),
|
||||
None => "Anonymous".to_owned(),
|
||||
},
|
||||
pubdate: match pb.pubdate {
|
||||
Some(pubdate) => DateTime::from(DateTime::parse_from_rfc3339(&pubdate.to_string()).expect("valid rfc3339 datetime")),
|
||||
None => Utc::now(),
|
||||
},
|
||||
url: match pb.url {
|
||||
Some(url) => url.clone(),
|
||||
None => "".to_owned(),
|
||||
},
|
||||
description: match pb.description {
|
||||
Some(description) => super::super::format_markdown(&description).expect("book description is valid markdown"),
|
||||
None => "".to_owned(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
@import 'variables';
|
||||
@import 'base';
|
||||
@import 'layout';
|
||||
@import 'toc';
|
||||
@import 'icons';
|
||||
@import 'darktheme';
|
||||
@import 'print';
|
@ -0,0 +1,101 @@
|
||||
body.toc {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
>* {
|
||||
width: 36em;
|
||||
}
|
||||
|
||||
header {
|
||||
margin-top: 1em;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
h1 {
|
||||
font-size: 3em;
|
||||
font-weight: 700;
|
||||
font-family: $font-sansserif;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1em;
|
||||
font-weight: 600;
|
||||
font-family: $font-sansserif;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
time {
|
||||
font-size: 1em;
|
||||
font-weight: 400;
|
||||
font-family: $font-serif;
|
||||
}
|
||||
}
|
||||
|
||||
nav {
|
||||
background: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
h1 {
|
||||
text-align: left;
|
||||
font-size: 2.5em;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
ol {
|
||||
margin: 0.25em 0 0;
|
||||
li {
|
||||
font-size: 1.5em;
|
||||
font-family: $font-sansserif;
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
margin: 0 0 0.25em 0;
|
||||
color: #5babd1;
|
||||
|
||||
&:hover {
|
||||
color: #cf5ccd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
body.toc {
|
||||
>* {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
header {
|
||||
h1, h2, time {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
article, nav {
|
||||
padding: 0;
|
||||
>* {
|
||||
margin-left: 0.5em;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
nav {
|
||||
h1 {
|
||||
font-size: 1.75em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{ book.title }}</title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
|
||||
<link rel="shortcut icon" href="favicon.ico" />
|
||||
<meta property="og:title" content="{{ book.title }}" />
|
||||
<meta property="og:site_name" content="{{ book.title }}" />
|
||||
<meta property="og:type" content="book" />
|
||||
<meta property="og:url" content="{{ book.url|safe }}" />
|
||||
<meta property="og:description" content="{{ book.description }}" />
|
||||
<meta property="book:author" content="{{ book.author }}" />
|
||||
<meta property="book:release_date" content="{{ book.pubdate|rfc3339_utc }}" />
|
||||
</head>
|
||||
<body class="toc">
|
||||
<header>
|
||||
<h1>{{ book.title }}</h1>
|
||||
<h2>by {{ book.author }}</h2>
|
||||
<time datetime="{{ book.pubdate|rfc3339_utc }}">{{ book.pubdate|human_date }}</time>
|
||||
</header>
|
||||
<article>
|
||||
{{ book.description|safe }}
|
||||
</article>
|
||||
<nav>
|
||||
<h1>Table of Contents</h1>
|
||||
<ol>
|
||||
{% for chapter in chapters %}
|
||||
<li><a href="{{ chapter.url|safe }}">{{ chapter.title }}</a></li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</nav>
|
||||
<footer><p>© {{ book.pubdate|year }} {{ book.author }}</p></footer>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue