Fix, and test, the no-js toc sidebar with hashed resources
To make this work, I need to break the circular dependency and stop hashing toc.html itself.
This commit is contained in:
parent
ec157cd1cd
commit
8a9ecd212d
4 changed files with 21 additions and 14 deletions
|
|
@ -392,16 +392,11 @@ impl Renderer for HtmlHandlebars {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Render toc");
|
debug!("Render toc js");
|
||||||
{
|
{
|
||||||
let rendered_toc = handlebars.render("toc_js", &data)?;
|
let rendered_toc = handlebars.render("toc_js", &data)?;
|
||||||
static_files.add_builtin("toc.js", rendered_toc.as_bytes());
|
static_files.add_builtin("toc.js", rendered_toc.as_bytes());
|
||||||
debug!("Creating toc.js ✓");
|
debug!("Creating toc.js ✓");
|
||||||
data.insert("is_toc_html".to_owned(), json!(true));
|
|
||||||
let rendered_toc = handlebars.render("toc_html", &data)?;
|
|
||||||
static_files.add_builtin("toc.html", rendered_toc.as_bytes());
|
|
||||||
debug!("Creating toc.html ✓");
|
|
||||||
data.remove("is_toc_html");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if html_config.hash_files {
|
if html_config.hash_files {
|
||||||
|
|
@ -415,6 +410,17 @@ impl Renderer for HtmlHandlebars {
|
||||||
|
|
||||||
handlebars.register_helper("resource", Box::new(resource_helper));
|
handlebars.register_helper("resource", Box::new(resource_helper));
|
||||||
|
|
||||||
|
debug!("Render toc html");
|
||||||
|
{
|
||||||
|
data.insert("is_toc_html".to_owned(), json!(true));
|
||||||
|
data.insert("path".to_owned(), json!("toc.html"));
|
||||||
|
let rendered_toc = handlebars.render("toc_html", &data)?;
|
||||||
|
utils::fs::write_file(destination, "toc.html", rendered_toc.as_bytes())?;
|
||||||
|
debug!("Creating toc.html ✓");
|
||||||
|
data.remove("path");
|
||||||
|
data.remove("is_toc_html");
|
||||||
|
}
|
||||||
|
|
||||||
utils::fs::write_file(
|
utils::fs::write_file(
|
||||||
destination,
|
destination,
|
||||||
".nojekyll",
|
".nojekyll",
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@
|
||||||
<!-- populated by js -->
|
<!-- populated by js -->
|
||||||
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
|
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
|
||||||
<noscript>
|
<noscript>
|
||||||
<iframe class="sidebar-iframe-outer" src="{{ resource "toc.html" }}"></iframe>
|
<iframe class="sidebar-iframe-outer" src="{{ path_to_root }}toc.html"></iframe>
|
||||||
</noscript>
|
</noscript>
|
||||||
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
||||||
<div class="sidebar-resize-indicator"></div>
|
<div class="sidebar-resize-indicator"></div>
|
||||||
|
|
|
||||||
|
|
@ -21,20 +21,20 @@
|
||||||
{{> head}}
|
{{> head}}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#ffffff">
|
<meta name="theme-color" content="#ffffff">
|
||||||
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
|
<link rel="stylesheet" href="{{ resource "css/variables.css" }}">
|
||||||
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
|
<link rel="stylesheet" href="{{ resource "css/general.css" }}">
|
||||||
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
|
<link rel="stylesheet" href="{{ resource "css/chrome.css" }}">
|
||||||
{{#if print_enable}}
|
{{#if print_enable}}
|
||||||
<link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
|
<link rel="stylesheet" href="{{ resource "css/print.css" }}" media="print">
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
|
<link rel="stylesheet" href="{{ resource "FontAwesome/css/font-awesome.css" }}">
|
||||||
{{#if copy_fonts}}
|
{{#if copy_fonts}}
|
||||||
<link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
|
<link rel="stylesheet" href="{{ resource "fonts/fonts.css" }}">
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<!-- Custom theme stylesheets -->
|
<!-- Custom theme stylesheets -->
|
||||||
{{#each additional_css}}
|
{{#each additional_css}}
|
||||||
<link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
|
<link rel="stylesheet" href="{{ resource this }}">
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</head>
|
</head>
|
||||||
<body class="sidebar-iframe-inner">
|
<body class="sidebar-iframe-inner">
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ edition = "2018"
|
||||||
|
|
||||||
[output.html]
|
[output.html]
|
||||||
mathjax-support = true
|
mathjax-support = true
|
||||||
|
hash-files = true
|
||||||
|
|
||||||
[output.html.playground]
|
[output.html.playground]
|
||||||
editable = true
|
editable = true
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue