Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
iamayushdas committed May 20, 2021
1 parent 63ca529 commit faf78cf
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 12 deletions.
22 changes: 11 additions & 11 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,17 @@ module.exports = {
src: "img/logo2.svg",
},
items: [
{
type: 'docsVersionDropdown',
position: 'left',
dropdownActiveClassDisabled: true,
dropdownItemsAfter: [
{
to: '/versions',
label: 'All versions',
},
],
},
{
label: "Docs",
position: "right",
Expand Down Expand Up @@ -345,17 +356,6 @@ module.exports = {
type: "localeDropdown",
position: "right",
},
{
type: 'docsVersionDropdown',
position: 'left',
dropdownActiveClassDisabled: true,
dropdownItemsAfter: [
{
to: '/versions',
label: 'All versions',
},
],
},
],
},
hideableSidebar: true,
Expand Down
107 changes: 107 additions & 0 deletions website/src/pages/versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Link from '@docusaurus/Link';
import Layout from '@theme/Layout';

import {useVersions, useLatestVersion} from '@theme/hooks/useDocs';

function Version() {
const {siteConfig} = useDocusaurusContext();
const versions = useVersions();
const latestVersion = useLatestVersion();
const currentVersion = versions.find((version) => version.name === 'current');
const pastVersions = versions.filter(
(version) => version !== latestVersion && version.name !== 'current',
);
const repoUrl = `https://github.com/${siteConfig.organizationName}/${siteConfig.projectName}`;

return (
<Layout
title="Versions"
description="Docusaurus 2 Versions page listing all documented site versions">
<main className="container margin-vert--lg">
<h1>Apache APISIX documentation versions</h1>

{latestVersion && (
<div className="margin-bottom--lg">
<h3 id="next">Current version (Stable)</h3>
<p>
Here you can find the documentation for current released version.
</p>
<table>
<tbody>
<tr>
<th>{latestVersion.label}</th>
<td>
<Link to={latestVersion.path}>Documentation</Link>
</td>
<td>
<a href={`${repoUrl}/releases/tag/v${latestVersion.name}`}>
Release Notes
</a>
</td>
</tr>
</tbody>
</table>
</div>
)}

{currentVersion !== latestVersion && (
<div className="margin-bottom--lg">
<h3 id="latest">Next version (Unreleased)</h3>
<p>
Here you can find the documentation for work-in-process unreleased
version.
</p>
<table>
<tbody>
<tr>
<th>{currentVersion.label}</th>
<td>
<Link to={currentVersion.path}>Documentation</Link>
</td>
</tr>
</tbody>
</table>
</div>
)}

{pastVersions.length > 0 && (
<div className="margin-bottom--lg">
<h3 id="archive">Past versions (Not maintained anymore)</h3>
<p>
Here you can find documentation for previous versions of
Docusaurus.
</p>
<table>
<tbody>
{pastVersions.map((version) => (
<tr key={version.name}>
<th>{version.label}</th>
<td>
<Link to={version.path}>Documentation</Link>
</td>
<td>
<a href={`${repoUrl}/releases/tag/v${version.name}`}>
Release Notes
</a>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</main>
</Layout>
);
}

export default Version;
13 changes: 12 additions & 1 deletion website/src/theme/DocPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useState, useCallback } from "react";
import React, { useState, useCallback, useEffect } from "react";
import { MDXProvider } from "@mdx-js/react";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import renderRoutes from "@docusaurus/renderRoutes";
Expand All @@ -26,6 +26,16 @@ function DocPageContent({ currentDocRoute, versionMetadata, children }) {
docsSidebars,
version,
} = versionMetadata;

useEffect(() => {
console.log(docsSidebars[sidebarName][0].label);
if(docsSidebars[sidebarName][0].label !== "Apache APISIX"){
document.querySelector(".dropdown--left").style.display = "none";
}
return () => {
}
}, []);

const sidebarName = permalinkToSidebar[currentDocRoute.path];
const sidebar = docsSidebars[sidebarName];
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
Expand Down Expand Up @@ -122,6 +132,7 @@ function DocPage(props) {
const currentDocRoute = docRoutes.find((docRoute) =>
matchPath(location.pathname, docRoute)
);
console.log(currentDocRoute.path);

if (!currentDocRoute) {
return <NotFound {...props} />;
Expand Down

0 comments on commit faf78cf

Please sign in to comment.