Don't let robots index the print.html (#844)

This commit is contained in:
Philipp Hansch 2019-05-08 00:32:43 +02:00 committed by Dylan DPC
parent ecfaed1e02
commit 5163c5ab75
2 changed files with 18 additions and 0 deletions

View File

@ -4,6 +4,10 @@
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>{{ title }}</title>
{{#if is_print }}
<meta name="robots" content="noindex" />
{{/if}}
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="{{ description }}">
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -415,6 +415,20 @@ fn theme_dir_overrides_work_correctly() {
dummy_book::assert_contains_strings(built_index, &["This is a modified index.hbs!"]);
}
#[test]
fn no_index_for_print_html() {
let temp = DummyBook::new().build().unwrap();
let md = MDBook::load(temp.path()).unwrap();
md.build().unwrap();
let print_html = temp.path().join("book/print.html");
assert_contains_strings(print_html, &[r##"noindex"##]);
let index_html = temp.path().join("book/index.html");
assert_doesnt_contain_strings(index_html, &[r##"noindex"##]);
}
#[cfg(feature = "search")]
mod search {
extern crate serde_json;