Skip to content

Commit

Permalink
fix(theme): Fix side menu being stuck open and obscuring most of the …
Browse files Browse the repository at this point in the history
…page
  • Loading branch information
simonsan committed Oct 4, 2023
1 parent 675591b commit d512065
Show file tree
Hide file tree
Showing 5 changed files with 930 additions and 783 deletions.
7 changes: 6 additions & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ site-url = "/patterns/"
git-repository-url = "https://github.com/rust-unofficial/patterns"
git-repository-icon = "fa-github"
edit-url-template = "https://github.com/rust-unofficial/patterns/edit/main/{path}"
additional-css = ["./language-picker.css"]
additional-css = ["theme/css/language-picker.css"]

[output.html.fold]
enable = true
Expand All @@ -33,3 +33,8 @@ level = 1
editable = false

# [output.linkcheck] # enable the "mdbook-linkcheck" renderer, disabled due to gh-actions

[output.html.redirect]
# Redirects in the form of "old-path" = "new-path", where the new path
# is relative to the old path.
"functional/lenses.html" = "optics.html"
5 changes: 5 additions & 0 deletions language-picker.css → theme/css/language-picker.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
right: 10px;
}

[dir="rtl"] #language-list {
left: 10px;
right: auto;
}

#language-list a {
color: inherit;
}
26 changes: 26 additions & 0 deletions theme/head.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{! Move to template code after fixing this issue:
https://github.com/google/mdbook-i18n-helpers/issues/70 }}
<script>
(function () {
// See these pages for details:
// https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls
// https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics
let base = "https://rust-unofficial.github.io/patterns";
{{#if(eq language "en")}}
let canonical_href = `${base}/{{ path }}`;
{{else}}
let canonical_href = `${base}/{{ language }}/{{ path }}`;
{{/if}}
// mdbook gives us a string ending in ".md", we replace it with ".html":
canonical_href = canonical_href.slice(0, -"md".length) + "html";
if (canonical_href.endsWith("/index.html")) {
canonical_href = canonical_href.slice(0, -"index.html".length);
}
let link = document.createElement("link");
link.rel = "canonical";
link.href = canonical_href;
document.head.appendChild(link);
}) ()
</script>
Loading

0 comments on commit d512065

Please sign in to comment.