Files
twenty/packages/twenty-website/src/shared-utils/getCardPath.tsx
T
Ady Beraud ff1bca1816 Docs modifications (#5804)
- Fixes #5504
- Fixes #5503
- Return 404 when the page does not exist
- Modified the footer in order to align it properly
- Removed "noticed something to change" in each table of content
- Fixed the URLs of the edit module 
- Added the edit module to Developers
- Fixed header style on the REST API page.
- Edited the README to point to Developers
- Fixed selected state when clicking on sidebar elements

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
2024-06-11 09:45:17 +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 `${basePath}/${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}`;
}
}
};