Skip to content

Commit

Permalink
fix bugs in React
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahs committed Jun 23, 2021
1 parent 15e33f0 commit 1187479
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions components/SidebarNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useVersion } from './hooks/useVersion'

export const SidebarNav = () => {
const router = useRouter()
const { error, relativePath } = useMainContext()
const { error, relativePath, isFPT } = useMainContext()
const { t } = useTranslation('header')

return (
Expand Down Expand Up @@ -39,7 +39,7 @@ export const SidebarNav = () => {
<nav>
{error === '404' || relativePath === 'index.md' ? (
<ul className="sidebar-products mt-4">
{<AllProductsLink />}
{!isFPT && <AllProductsLink />}
<SidebarHomepage />
</ul>
) : (
Expand All @@ -66,17 +66,17 @@ export const SidebarNav = () => {
const SidebarHomepage = () => {
const router = useRouter()
const { currentVersion } = useVersion()
const { activeProducts } = useMainContext()
const { activeProducts, isFPT } = useMainContext()

return (
<>
{activeProducts.map((product) => {
if (!product.versions?.includes(currentVersion) && !product.external) {
if (!isFPT && !product.versions?.includes(currentVersion) && !product.external) {
return null
}

const href = `${!product.external ? `/${router.locale}` : ''}${
product.versions?.includes(currentVersion)
product.versions?.includes(currentVersion) && !isFPT
? `/${currentVersion}/${product.id}`
: product.href
}`
Expand Down
2 changes: 2 additions & 0 deletions components/context/MainContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export type MainContextT = {
currentProduct?: ProductT
currentLayoutName: string
isHomepageVersion: boolean
isFPT: boolean
data: DataT
airGap?: boolean
error: string
Expand Down Expand Up @@ -116,6 +117,7 @@ export const getMainContextFromRequest = (req: any): MainContextT => {
currentProduct: req.context.productMap[req.context.currentProduct] || null,
currentLayoutName: req.context.currentLayoutName,
isHomepageVersion: req.context.page?.documentType === 'homepage',
isFPT: req.context.currentVersion === 'free-pro-team@latest',
error: req.context.error ? req.context.error.toString() : '',
data: {
ui: req.context.site.data.ui,
Expand Down
6 changes: 3 additions & 3 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type LandingPageProps = {
function LandingPage(props: LandingPageProps) {
const router = useRouter()
const { gettingStartedLinks, popularLinks } = props
const { activeProducts } = useMainContext()
const { activeProducts, isFPT } = useMainContext()
const { currentVersion } = useVersion()
const { t } = useTranslation(['homepage', 'search', 'toc'])
return (
Expand Down Expand Up @@ -80,12 +80,12 @@ function LandingPage(props: LandingPageProps) {
</h2>
<div className="d-flex flex-wrap gutter gutter-xl-spacious">
{activeProducts.map((product) => {
if (!product.versions?.includes(currentVersion) && !product.external) {
if (!isFPT && !product.versions?.includes(currentVersion) && !product.external) {
return null
}

const href = `${!product.external ? `/${router.locale}` : ''}${
product.versions?.includes(currentVersion)
product.versions?.includes(currentVersion) && !isFPT
? `/${currentVersion}/${product.id}`
: product.href
}`
Expand Down

0 comments on commit 1187479

Please sign in to comment.