1
0
mirror of synced 2025-12-23 11:54:18 -05:00

Revert "Fix homepage versions dropdown" (#20087)

This commit is contained in:
Matt Pollard
2021-06-23 09:11:51 +02:00
committed by GitHub
parent 7aa96e48b8
commit f9f0b2ce86
14 changed files with 58 additions and 16 deletions

View File

@@ -10,7 +10,7 @@ import { useVersion } from './hooks/useVersion'
export const SidebarNav = () => {
const router = useRouter()
const { error, relativePath } = useMainContext()
const { error, relativePath, isHomepageVersion } = useMainContext()
const { t } = useTranslation('header')
return (
@@ -39,7 +39,7 @@ export const SidebarNav = () => {
<nav>
{error === '404' || relativePath === 'index.md' ? (
<ul className="sidebar-products mt-4">
{<AllProductsLink />}
{!isHomepageVersion && <AllProductsLink />}
<SidebarHomepage />
</ul>
) : (
@@ -66,12 +66,12 @@ export const SidebarNav = () => {
const SidebarHomepage = () => {
const router = useRouter()
const { currentVersion } = useVersion()
const { activeProducts } = useMainContext()
const { activeProducts, isHomepageVersion } = useMainContext()
return (
<>
{activeProducts.map((product) => {
if (!product.versions?.includes(currentVersion) && !product.external) {
if (!product.versions?.includes(currentVersion) && !isHomepageVersion) {
return null
}

View File

@@ -31,6 +31,10 @@ export const ArticleVersionPicker = () => {
</summary>
<Dropdown.Menu direction="sw">
{(page.permalinks || []).map((permalink) => {
if (permalink.pageVersion === 'homepage') {
return null
}
return (
<Dropdown.Item key={permalink.href}>
<Link href={permalink.href}>{permalink.pageVersionTitle}</Link>

View File

@@ -115,7 +115,7 @@ export const getMainContextFromRequest = (req: any): MainContextT => {
activeProducts: req.context.activeProducts,
currentProduct: req.context.productMap[req.context.currentProduct] || null,
currentLayoutName: req.context.currentLayoutName,
isHomepageVersion: req.context.page?.documentType === 'homepage',
isHomepageVersion: req.context.currentVersion === 'homepage',
error: req.context.error ? req.context.error.toString() : '',
data: {
ui: req.context.site.data.ui,

View File

@@ -6,6 +6,7 @@ import { ChevronDownIcon } from '@primer/octicons-react'
import { Link } from 'components/Link'
import { useMainContext } from 'components/context/MainContext'
import { useVersion } from 'components/hooks/useVersion'
import { useTranslation } from 'components/hooks/useTranslation'
type Props = {
variant?: 'inline'
@@ -14,13 +15,14 @@ export const HomepageVersionPicker = ({ variant }: Props) => {
const router = useRouter()
const { currentVersion } = useVersion()
const { getDetailsProps } = useDetails({})
const { allVersions, page, enterpriseServerVersions } = useMainContext()
const { allVersions, page, enterpriseServerVersions, isHomepageVersion } = useMainContext()
const { t } = useTranslation('homepage')
if (page.permalinks && page.permalinks.length <= 1) {
return null
}
const label = allVersions[currentVersion].versionTitle
const label = isHomepageVersion ? t('version_picker') : allVersions[currentVersion].versionTitle
if (variant === 'inline') {
return (
@@ -33,6 +35,9 @@ export const HomepageVersionPicker = ({ variant }: Props) => {
</summary>
<div>
{(page.permalinks || []).map((permalink) => {
if (permalink.pageVersion === 'homepage') {
return null
}
return (
<Link
key={permalink.href}
@@ -73,6 +78,10 @@ export const HomepageVersionPicker = ({ variant }: Props) => {
</summary>
<Dropdown.Menu direction="sw">
{(page.permalinks || []).map((permalink) => {
if (permalink.pageVersion === 'homepage') {
return null
}
return (
<Dropdown.Item key={permalink.href}>
<Link href={permalink.href}>{permalink.pageVersionTitle}</Link>