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,27 +42,24 @@ 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}`
const pathnamePrefix = `/${locale}${version}/rest/`
const content = Object.entries(enabledForApps)
.filter(([, operations]) => operations.length)
.map(([category, operations]) => (
<Fragment key={category}> <Fragment key={category}>
{operations.length > 0 && (
<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={`enabledAppOperation-${operation.slug}-${index}`}> <li key={`${category}-${operation.slug}-${index}`}>
<Link <Link
href={`/${locale}${ href={`${pathnamePrefix}${category}${
currentVersion === 'free-pro-team@latest' ? '' : '/' + currentVersion categoriesWithoutSubcategories.includes(category)
}/rest/${category}${ ? ''
categoriesWithoutSubcategories.includes(category) ? '' : '/' + operation.subcategory : '/' + operation.subcategory
}#${operation.slug}`} }#${operation.slug}`}
> >
<code> <code>