@@ -3,6 +3,7 @@ | |||
## 0.0.5 (unreleased) | |||
- Fix XML templates overriding and reloading | |||
- `title` and `description` are now optional in the front matter | |||
## 0.0.4 (2017-04-23) | |||
@@ -80,8 +80,10 @@ description = "Some meta info" | |||
A simple page with fixed url | |||
``` | |||
A front-matter requires a title, a description and has the following optional variables: | |||
A front-matter has only optional variables: | |||
- title | |||
- description | |||
- date: a YYYY-MM-DD or RFC339 formatted date | |||
- slug: what slug to use in the url | |||
- url: this overrides the slug and make this page accessible at `{config.base_url}/{url}` | |||
@@ -90,6 +92,7 @@ A front-matter requires a title, a description and has the following optional va | |||
- draft: whether the post is a draft or not | |||
- template: if you want to change the template used to render that specific page | |||
Even if your front-matter is empty, you will need to put the `+++`. | |||
You can also, like in the config, add your own variables in a `[extra]` table. | |||
The front-matter will be accessible in templates at the `page.meta` field. | |||
@@ -114,11 +117,9 @@ This `_index.md` file needs to include a front-matter as well, but won't have co | |||
```md | |||
+++ | |||
title = "Tutorials" | |||
description = "" | |||
+++ | |||
``` | |||
Both `title` and `description` are mandatory, you can also set the `template` variable to change | |||
which template will be used to render that section. | |||
You can also set the `template` variable to change which template will be used to render that section. | |||
Sections will also automatically pick up their subsections, allowing you to make some complex pages layout and | |||
table of contents. | |||
@@ -152,8 +153,7 @@ built-in: | |||
- solarized-dark | |||
- solarized-light | |||
### Internal | |||
s | |||
### Internal links | |||
You can have internal links in your markdown that will be replaced with the full URL when rendering. | |||
To do so, use the normal markdown link syntax, start the link with `./` and point to the `.md` file you want | |||
to link to. The path to the file starts from the `content` directory. | |||
@@ -18,15 +18,10 @@ lazy_static! { | |||
/// The front matter of every page | |||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | |||
pub struct FrontMatter { | |||
// Mandatory fields | |||
/// <title> of the page | |||
pub title: String, | |||
/// Description that appears when linked, e.g. on twitter | |||
pub description: String, | |||
// Optional stuff | |||
pub title: Option<String>, | |||
/// Description in <meta> that appears when linked, e.g. on twitter | |||
pub description: Option<String>, | |||
/// Date if we want to order pages (ie blog post) | |||
pub date: Option<String>, | |||
/// The page slug. Will be used instead of the filename if present | |||
@@ -16,8 +16,8 @@ description = "hey there""#; | |||
println!("{:?}", res); | |||
assert!(res.is_ok()); | |||
let res = res.unwrap(); | |||
assert_eq!(res.title, "Hello".to_string()); | |||
assert_eq!(res.description, "hey there".to_string()); | |||
assert_eq!(res.title.unwrap(), "Hello".to_string()); | |||
assert_eq!(res.description.unwrap(), "hey there".to_string()); | |||
} | |||
#[test] | |||
@@ -31,7 +31,7 @@ tags = ["rust", "html"]"#; | |||
assert!(res.is_ok()); | |||
let res = res.unwrap(); | |||
assert_eq!(res.title, "Hello".to_string()); | |||
assert_eq!(res.title.unwrap(), "Hello".to_string()); | |||
assert_eq!(res.slug.unwrap(), "hello-world".to_string()); | |||
assert_eq!(res.tags.unwrap(), ["rust".to_string(), "html".to_string()]); | |||
} | |||
@@ -50,7 +50,7 @@ authors = ["Bob", "Alice"]"#; | |||
assert!(res.is_ok()); | |||
let res = res.unwrap(); | |||
assert_eq!(res.title, "Hello".to_string()); | |||
assert_eq!(res.title.unwrap(), "Hello".to_string()); | |||
assert_eq!(res.slug.unwrap(), "hello-world".to_string()); | |||
let extra = res.extra.unwrap(); | |||
assert_eq!(extra["language"], to_value("en").unwrap()); | |||
@@ -87,13 +87,6 @@ fn test_errors_with_invalid_front_matter() { | |||
assert!(res.is_err()); | |||
} | |||
#[test] | |||
fn test_errors_with_missing_required_value_front_matter() { | |||
let content = r#"title = """#; | |||
let res = FrontMatter::parse(content); | |||
assert!(res.is_err()); | |||
} | |||
#[test] | |||
fn test_errors_on_non_string_tag() { | |||
let content = r#" | |||
@@ -168,7 +161,7 @@ Hello | |||
"#; | |||
let (front_matter, content) = split_content(Path::new(""), content).unwrap(); | |||
assert_eq!(content, "Hello\n"); | |||
assert_eq!(front_matter.title, "Title"); | |||
assert_eq!(front_matter.title.unwrap(), "Title"); | |||
} | |||
#[test] | |||
@@ -181,7 +174,7 @@ date = "2002/10/12" | |||
+++"#; | |||
let (front_matter, content) = split_content(Path::new(""), content).unwrap(); | |||
assert_eq!(content, ""); | |||
assert_eq!(front_matter.title, "Title"); | |||
assert_eq!(front_matter.title.unwrap(), "Title"); | |||
} | |||
#[test] | |||
@@ -195,7 +188,7 @@ date = "2002-10-02T15:00:00Z" | |||
+++"#; | |||
let (front_matter, content) = split_content(Path::new(""), content).unwrap(); | |||
assert_eq!(content, "+++"); | |||
assert_eq!(front_matter.title, "Title"); | |||
assert_eq!(front_matter.title.unwrap(), "Title"); | |||
} | |||
#[test] | |||
@@ -26,7 +26,7 @@ Hello world"#; | |||
let mut page = res.unwrap(); | |||
page.render_markdown(&HashMap::default(), &Tera::default(), &Config::default()).unwrap(); | |||
assert_eq!(page.meta.title, "Hello".to_string()); | |||
assert_eq!(page.meta.title.unwrap(), "Hello".to_string()); | |||
assert_eq!(page.meta.slug.unwrap(), "hello-world".to_string()); | |||
assert_eq!(page.raw_content, "Hello world".to_string()); | |||
assert_eq!(page.content, "<p>Hello world</p>\n".to_string()); | |||