diff --git a/lib/core/BlogPageLayout.js b/lib/core/BlogPageLayout.js index 771e4fc5ed..6bfebc6b25 100644 --- a/lib/core/BlogPageLayout.js +++ b/lib/core/BlogPageLayout.js @@ -28,7 +28,6 @@ const BlogPageLayout = React.createClass({ const page = this.props.metadata.page; return ( + + ); - } else { - updatedLink = updatedLink.replace(/\/VERSION\//, "/"); + } else if (link.languages) { + return ( + + ); + } else if (link.doc) { + let id; + if (!ENABLE_VERSIONING || this.props.version === "next") { + id = this.props.language + "-" + link.doc; + } else { + id = + this.props.language + + "-version-" + + (this.props.version || versions[0]) + + "-" + + link.doc; + } + href = this.props.config.baseUrl + Metadata[id].permalink; + } else if (link.page) { + if (fs.existsSync(CWD + "/pages/en/" + link.page + ".js")) { + href = + siteConfig.baseUrl + this.props.language + "/" + link.page + ".html"; + } else { + href = siteConfig.baseUrl + link.page + ".html"; + } + } else if (link.href) { + href = link.href; } return ( -
  • - +
  • + {translation[this.props.language] - ? translation[this.props.language]["localized-strings"][link.text] - : link.text} - -
  • - ); - } - - makeExternalLinks(link) { - return ( -
  • - - {translation[this.props.language] - ? translation[this.props.language]["localized-strings"][link.text] - : link.text} + ? translation[this.props.language]["localized-strings"][link.label] + : link.label}
  • ); @@ -174,30 +181,32 @@ class HeaderNav extends React.Component { } renderResponsiveNav() { + const headerLinks = this.props.config.headerLinks; + // add language drop down to end if location not specified + let languages = false; + headerLinks.forEach(link => { + if (link.languages) { + languages = true; + } + }); + if (!languages) { + headerLinks.push({ languages: true }); + } + // add search bar to end if location not specified + let search = false; + headerLinks.forEach(link => { + if (link.search) { + search = true; + } + }); + if (!search && this.props.config.algolia) { + headerLinks.push({ search: true }); + } return (
    diff --git a/lib/write-translations.js b/lib/write-translations.js index 18ca29b8ec..a886d86da8 100755 --- a/lib/write-translations.js +++ b/lib/write-translations.js @@ -57,14 +57,11 @@ function execute() { } }); /* look through header links for text to translate */ - for (let i = 0; i < siteConfig.headerLinksInternal.length; i++) { - translations["localized-strings"][siteConfig.headerLinksInternal[i].text] = - siteConfig.headerLinksInternal[i].text; - } - for (let i = 0; i < siteConfig.headerLinksExternal.length; i++) { - translations["localized-strings"][siteConfig.headerLinksExternal[i].text] = - siteConfig.headerLinksExternal[i].text; - } + siteConfig.headerLinks.forEach(link => { + if (link.label) { + translations["localized-strings"][link.label] = link.label; + } + }); /* find sidebar category titles to translate */ Object.keys(sidebars).forEach(sb => { diff --git a/website/siteConfig.js b/website/siteConfig.js index 1067399e7f..28db207244 100644 --- a/website/siteConfig.js +++ b/website/siteConfig.js @@ -26,19 +26,12 @@ const siteConfig = { users, editUrl: "https://github.com/facebookexperimental/docusaurus/edit/master/docs/", - headerLinksInternal: [ + headerLinks: [ + { doc: "installation", label: "Docs" }, + { page: "help", label: "Help" }, { - section: "docs", - href: "/docusaurus/docs/installation.html", - text: "Docs" - }, - { section: "help", href: "/docusaurus/LANGUAGE/help.html", text: "Help" } - ], - headerLinksExternal: [ - { - section: "github", href: "https://github.com/facebookexperimental/docusaurus", - text: "GitHub" + label: "GitHub" } ], headerIcon: "img/docusaurus.svg", @@ -55,8 +48,7 @@ const siteConfig = { colors: { primaryColor: "#2E8555", secondaryColor: "#205C3B", - prismColor: - "rgba(46, 133, 85, 0.03)" + prismColor: "rgba(46, 133, 85, 0.03)" } };