Files
twenty/packages/twenty-website/src/shared-utils/getCardPath.tsx
Félix Malfait dbaa787d19 website / Fix broken links, slow loading, and prod errors (#5932)
The code is in a bad state, this is just fixing it but not improving the
structure
2024-06-18 18:40:19 +02:00

36 lines
1.1 KiB
TypeScript

import { DocsArticlesProps } from '@/content/user-guide/constants/getDocsArticles';
export const getCardPath = (
card: DocsArticlesProps,
basePath: string,
isSection: boolean,
sectionName?: string,
) => {
const isPlayground = [
'core-api-rest',
'metadata-api-rest',
'core-api-graphql',
'metadata-api-graphql',
];
if (isPlayground.includes(card.fileName)) {
const apiType = card.fileName.includes('rest') ? 'rest-api' : 'graphql';
const apiName = card.fileName.includes('core') ? 'core' : 'metadata';
return `/developers/${apiType}/${apiName}`;
} else if (card.fileName.includes('storybook')) {
return 'https://storybook.twenty.com';
} else if (card.fileName.includes('components')) {
return `/twenty-ui`;
} else {
if (sectionName) {
return card.numberOfFiles > 1
? `${basePath}section/${sectionName}/${card.fileName}`
: `${basePath}${card.fileName}`;
} else {
return card.numberOfFiles > 1 && !isSection
? `${basePath}/section/${card.fileName}`
: `${basePath}/${card.fileName}`;
}
}
};