diff --git a/content/_index.md b/content/_index.md index f166b082e..2ab9e38d7 100644 --- a/content/_index.md +++ b/content/_index.md @@ -7,5 +7,5 @@ This is the main Rust blog. \ Rust teams \ use this blog to announce major developments in the world of Rust.""" maintained_by = "the Rust Teams" -see_also_html = """the "Inside Rust" blog""" +see_also_html = """the "Inside Rust" blog""" +++ diff --git a/src/blogs.rs b/src/blogs.rs index afaef2eb8..26d7ef4e3 100644 --- a/src/blogs.rs +++ b/src/blogs.rs @@ -110,6 +110,10 @@ impl Blog { &self.path } + pub(crate) fn path_back_to_root(&self) -> PathBuf { + self.path.components().map(|_| Path::new("../")).collect() + } + pub(crate) fn posts(&self) -> &[Post] { &self.pages } diff --git a/src/lib.rs b/src/lib.rs index 2db10f173..f591108f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,6 +131,7 @@ impl Generator { let data = json!({ "title": blog.index_title(), "section": blog, + "root": blog.path_back_to_root(), }); let path = blog.path().join("index.html"); self.render_template(&path, "index.html", data)?; @@ -153,6 +154,7 @@ impl Generator { "title": format!("{} | {}", post.title, blog.title()), "section": blog, "page": post, + "root": blog.path_back_to_root().join("../../../"), }); let path = path.join(filename); diff --git a/templates/footer.html b/templates/footer.html index af5ff7c20..5e6e8145a 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,4 +1,4 @@ -{% macro footer() -%} +{% macro footer(root) -%} - + {% endmacro %} diff --git a/templates/headers.html b/templates/headers.html index 7be58147d..80194c04c 100644 --- a/templates/headers.html +++ b/templates/headers.html @@ -1,4 +1,4 @@ -{% macro headers(title, section) -%} +{% macro headers(title, section, root) -%} @@ -15,23 +15,23 @@ - - - - + + + + - - - - - - + + + + + + @@ -39,5 +39,5 @@ - + {% endmacro %} diff --git a/templates/layout.html b/templates/layout.html index 2488029cc..dfaa0a464 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -9,11 +9,11 @@ {{ macros::escape_hbs(input=title) }} - {{ headers::headers(title=title, section=section) | indent(prefix=" ", blank=true) }} + {{ headers::headers(title=title, section=section, root=root) | indent(prefix=" ", blank=true) }} - {{ nav::nav(section=section) | indent(prefix=" ", blank=true) }} + {{ nav::nav(section=section, root=root) | indent(prefix=" ", blank=true) }} {%- block page %}{% endblock page %} - {{ footer::footer() | indent(prefix=" ", blank=true) }} + {{ footer::footer(root=root) | indent(prefix=" ", blank=true) }} diff --git a/templates/nav.html b/templates/nav.html index 8759904f4..e8dfd9ea1 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -1,8 +1,8 @@ -{% macro nav(section) -%} +{% macro nav(section, root) -%} {% endmacro %}