From bd23d3ce5638970a9c6b0efbed15f3486cb51e63 Mon Sep 17 00:00:00 2001 From: Adam Kerrigan Date: Mon, 15 Feb 2021 17:01:43 +0000 Subject: [PATCH] Updated documentation to reflect changes to Chapter and preprocessors. --- guide/src/format/config.md | 21 +++++++++++++++++++++ guide/src/format/theme/index-hbs.md | 2 ++ 2 files changed, 23 insertions(+) diff --git a/guide/src/format/config.md b/guide/src/format/config.md index d9c77e66..bd83f62a 100644 --- a/guide/src/format/config.md +++ b/guide/src/format/config.md @@ -105,6 +105,25 @@ The following preprocessors are available and included by default: - `index`: Convert all chapter files named `README.md` into `index.md`. That is to say, all `README.md` would be rendered to an index file `index.html` in the rendered book. +- `metadata`: Reads an optional TOML header from the markdown chapter sources + to provide chapter specific information. This data is then made available to + handlebars.js. The supported fields are `author`, `title`, `description`, `keywords`, + `date` and `modified`. + +**Sample Chapter** +```toml +--- +author = "Jane Doe" # this is written to the author meta tag +title = "Blog Post #1" # this overwrites the default title handlebar +date = "2021/02/14" +keywords = [ + "Rust", + "Blog", +] # this sets the keywords meta tag +description = "A blog about rust-lang" # this sets the description meta tag +--- +This is my blog about rust. +``` **book.toml** @@ -116,6 +135,8 @@ create-missing = false [preprocessor.links] [preprocessor.index] + +[preprocessor.metadata] ``` ### Custom Preprocessor Configuration diff --git a/guide/src/format/theme/index-hbs.md b/guide/src/format/theme/index-hbs.md index e5331dcc..3c27ce8b 100644 --- a/guide/src/format/theme/index-hbs.md +++ b/guide/src/format/theme/index-hbs.md @@ -38,6 +38,8 @@ Here is a list of the properties that are exposed: containing all the chapters of the book. It is used for example to construct the table of contents (sidebar). +Further properties can be exposed through the `chapter_config` field of a `Chapter` which is accessible to preprocessors. + ## Handlebars Helpers In addition to the properties you can access, there are some handlebars helpers