1
0
mirror of synced 2025-12-19 18:10:59 -05:00

tidying iterator for Categories (#36417)

This commit is contained in:
Peter Bengtsson
2023-04-17 12:57:09 -04:00
committed by GitHub
parent e634d5dea4
commit c17716d067

View File

@@ -42,38 +42,35 @@ export default function Category({
}: Props) { }: Props) {
const { locale } = useRouter() const { locale } = useRouter()
const content = Object.entries(enabledForApps).map(([category, operations]) => ( const version = currentVersion === 'free-pro-team@latest' ? '' : `/${currentVersion}`
<Fragment key={category}> const pathnamePrefix = `/${locale}${version}/rest/`
{operations.length > 0 && (
const content = Object.entries(enabledForApps)
.filter(([, operations]) => operations.length)
.map(([category, operations]) => (
<Fragment key={category}>
<h3 id={category}> <h3 id={category}>
<Link <Link href={`${pathnamePrefix}${category}`}>{category}</Link>
href={`/${locale}${
currentVersion === 'free-pro-team@latest' ? '' : '/' + currentVersion
}/rest/${category}`}
>
{category}
</Link>
</h3> </h3>
)} <ul>
<ul> {operations.map((operation, index) => (
{operations.map((operation, index) => ( <li key={`${category}-${operation.slug}-${index}`}>
<li key={`enabledAppOperation-${operation.slug}-${index}`}> <Link
<Link href={`${pathnamePrefix}${category}${
href={`/${locale}${ categoriesWithoutSubcategories.includes(category)
currentVersion === 'free-pro-team@latest' ? '' : '/' + currentVersion ? ''
}/rest/${category}${ : '/' + operation.subcategory
categoriesWithoutSubcategories.includes(category) ? '' : '/' + operation.subcategory }#${operation.slug}`}
}#${operation.slug}`} >
> <code>
<code> <span className="text-uppercase">{operation.verb}</span> {operation.requestPath}
<span className="text-uppercase">{operation.verb}</span> {operation.requestPath} </code>
</code> </Link>
</Link> </li>
</li> ))}
))} </ul>
</ul> </Fragment>
</Fragment> ))
))
return ( return (
<MainContext.Provider value={mainContext}> <MainContext.Provider value={mainContext}>