-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement latest version banner (#3)
- Loading branch information
1 parent
d6523d4
commit a56c916
Showing
6 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.banner-container { | ||
background-color: var(--warning-background); | ||
border: 0 solid var(--warning-color); | ||
border-left-width: var(--admonition-border-left-width); | ||
border-radius: var(--admonition-border-radius); | ||
box-shadow: var(--admonition-border-box-shadow); | ||
padding: var(--admonition-padding); | ||
margin-left: 1rem; | ||
} | ||
|
||
@media screen and (min-width: 1024px) { | ||
.banner-container { | ||
width: 80%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ | |
@import "highlight.css"; | ||
@import "print.css"; | ||
@import "search.css"; | ||
@import "banners.css"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict' | ||
|
||
const VERSIONED_ROOT_RELATIVE_URL_RX = /^(\/[^/]+)\/[^/]+(?=\/)/ | ||
|
||
module.exports = ({ data: { root } }) => { | ||
const { contentCatalog, env, page } = root | ||
let { url, version, missing } = page.latest || { url: page.url } | ||
if (missing) { | ||
const latestAlias = contentCatalog.getById({ | ||
component: page.component.name, | ||
version, | ||
module: page.module, | ||
family: 'alias', | ||
relative: page.relativeSrcPath, | ||
}) | ||
if (!latestAlias) return | ||
url = latestAlias.rel.pub.url | ||
} | ||
if (url.charAt() === '/') { | ||
return env.SUPPORTS_CURRENT_URL === 'true' ? url.replace(VERSIONED_ROOT_RELATIVE_URL_RX, '$1/current') : url | ||
} else if (env.PRIMARY_SITE_SUPPORTS_CURRENT_URL === 'true') { | ||
const primarySiteUrl = page.componentVersion.asciidoc.attributes['primary-site-url'] | ||
return primarySiteUrl + url.substr(primarySiteUrl.length).replace(VERSIONED_ROOT_RELATIVE_URL_RX, '$1/current') | ||
} | ||
return url | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="doc banner-container" id="latest-banner"> | ||
<div> | ||
This is documentation for {{page.component.title}} <b>{{page.version}}</b>. | ||
</div> | ||
<div> | ||
For up-to-date documentation, see the {{#with (latest-page-url)}}<a href="{{relativize this}}">latest version</a>{{/with}} ({{page.component.latest.version}}). | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
<main class="article"> | ||
{{> toolbar}} | ||
<div class="content"> | ||
{{#if (eq page.layout '404')}} | ||
{{> article-404}} | ||
{{else}} | ||
{{> toc}} | ||
{{> article}} | ||
{{#if (ne page.version page.component.latest.version)}} | ||
{{> latest-banner}} | ||
{{/if}} | ||
<div class="content"> | ||
{{#if (eq page.layout '404')}} | ||
{{> article-404}} | ||
{{else}} | ||
{{> toc}} | ||
{{> article}} | ||
{{/if}} | ||
</div> | ||
</main> |