Skip to content

Commit

Permalink
chore(v2): update navbar logic (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Mar 20, 2019
1 parent 8802808 commit 527ff3e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions v2/lib/load/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const OPTIONAL_FIELDS = [
'customDocsPath',
'customFields',
'defaultLanguage',
'disableHeaderTitle',
'docsUrl',
'githubHost',
'highlight',
Expand Down
40 changes: 32 additions & 8 deletions v2/lib/theme/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ function Navbar(props) {
metadata = {},
docsMetadatas = {},
} = context;
const {baseUrl, headerLinks, headerIcon, algolia} = siteConfig;
const {
baseUrl,
headerLinks,
headerIcon,
algolia,
title,
disableHeaderTitle,
} = siteConfig;
const {language: thisLanguage, version: thisVersion} = metadata;

const translationEnabled = env.translation.enabled;
const versioningEnabled = env.versioning.enabled;
const defaultVersion = versioningEnabled && env.versioning.defaultVersion;

// function to generate each header link
const makeLinks = link => {
Expand Down Expand Up @@ -111,15 +119,31 @@ function Navbar(props) {
<div className={styles.navbarInner}>
<ul className={styles.navList}>
<li key="logo" className={styles.navListItem}>
<Link className={styles.navBrand} to="/">
<img
alt="Docusaurus Logo"
className={styles.navLogo}
src={baseUrl + headerIcon}
/>
<strong>Docusaurus</strong>
<Link
className={styles.navBrand}
to={baseUrl + (translationEnabled ? thisLanguage : '')}>
{headerIcon && (
<img
className={styles.navLogo}
src={baseUrl + headerIcon}
alt={title}
/>
)}
{!disableHeaderTitle && <strong>{title}</strong>}
</Link>
</li>
{versioningEnabled && (
<li key="versions" className={styles.navListItem}>
<Link
className={styles.navVersion}
to={
baseUrl +
(translationEnabled ? `${thisLanguage}/versions` : `versions`)
}>
{thisVersion || defaultVersion}
</Link>
</li>
)}
{headerLinks.map(makeLinks)}
</ul>
</div>
Expand Down
7 changes: 7 additions & 0 deletions v2/lib/theme/Navbar/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
text-decoration: none;
}

.navVersion {
color: black;
text-decoration: underline;
display: block;
padding: 1em 1.2em;
}

.navLogo {
height: 40px;
margin-right: 12px;
Expand Down

0 comments on commit 527ff3e

Please sign in to comment.