tidying iterator for Categories (#36417)
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user