Skip to content

Commit

Permalink
Add banner that points to latest version
Browse files Browse the repository at this point in the history
closes #1923

Only displays on doc pages for non-recent versions
  • Loading branch information
fatso83 committed Oct 12, 2018
1 parent df08556 commit e942d51
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
10 changes: 10 additions & 0 deletions docs/_includes/banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="bg-info hidden" id="banner-message">
These docs are from an older version of sinon.
Do you want the <a href="/releases/latest/">latest</a> docs?
</div>

<script>
if (site.showBanner) {
document.getElementById("banner-message").classList.remove("hidden");
}
</script>
8 changes: 7 additions & 1 deletion docs/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}" />
<link rel="stylesheet" href="{{ "/assets/css/main.css" | prepend: site.baseurl }}">
<link rel="shortcut icon" href="{{ "/assets/images/favicon.png" | prepend: site.baseurl }}">
<script>
var site = {}; // site settings
</script>

{% comment %}
To make all documentation pages, regardless of version, lead search traffic to the latest version,
Expand All @@ -14,8 +17,11 @@

{% assign url_parts = page.url | split: "/" %}

{%if page.url contains "/releases/v" %}
{%if page.url contains "/releases/v" and url_parts[2] != "latest" and url_parts[2] != {site.sinon.current_release} %}
{% assign canonical_page_url = "/releases/latest/" | append: url_parts[3] %}
<script>
site.showBanner = true; // cannot dynamically create a globally available Liquid variable
</script>
{% else %}
{% assign canonical_page_url = page.url | replace:'index.html','' %}
{% endif %}
Expand Down
2 changes: 2 additions & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

<div class="content">
<div class="container container-2">
{% include banner.html %}

{{ content }}
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions docs/_layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
---
<article class="post">

<header class="post-header">
<h1 class="post-title">{{ page.title }}</h1>
</header>
<header class="post-header">
<h1 class="post-title">{{ page.title }}</h1>
</header>

<div class="post-content">
{{ content }}
</div>
<div class="post-content">
{{ content }}
</div>

</article>
4 changes: 4 additions & 0 deletions docs/assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ body {
background: #fff;
}

.hidden {
display: none;
}

.navbar {
background: #fff;
margin-top: 10px;
Expand Down

0 comments on commit e942d51

Please sign in to comment.