mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
Add versioning functionality
This commit is contained in:
parent
58452ea963
commit
3598dffc58
12 changed files with 568 additions and 132 deletions
|
@ -92,14 +92,22 @@ class HeaderNav extends React.Component {
|
|||
}
|
||||
|
||||
makeInternalLinks(link) {
|
||||
const linkWithLang = link.href.replace(
|
||||
let updatedLink = link.href.replace(
|
||||
/\/LANGUAGE\//,
|
||||
"/" + this.props.language + "/"
|
||||
);
|
||||
if (this.props.version) {
|
||||
updatedLink = updatedLink.replace(
|
||||
/\/VERSION\//,
|
||||
"/" + this.props.version + "/"
|
||||
);
|
||||
} else {
|
||||
updatedLink = updatedLink.replace(/\/VERSION\//, "/");
|
||||
}
|
||||
return (
|
||||
<li key={link.section}>
|
||||
<a
|
||||
href={linkWithLang}
|
||||
href={updatedLink}
|
||||
className={link.section === this.props.section ? "active" : ""}
|
||||
>
|
||||
{translation[this.props.language]
|
||||
|
@ -111,14 +119,10 @@ class HeaderNav extends React.Component {
|
|||
}
|
||||
|
||||
makeExternalLinks(link) {
|
||||
const linkWithLang = link.href.replace(
|
||||
/\/LANGUAGE\//,
|
||||
"/" + this.props.language + "/"
|
||||
);
|
||||
return (
|
||||
<li key={link.section}>
|
||||
<a
|
||||
href={linkWithLang}
|
||||
href={link.href}
|
||||
className={link.section === this.props.section ? "active" : ""}
|
||||
target={siteConfig.externalLinkTarget || "_self"}
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue