The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
website / Fix broken links, slow loading, and prod errors (#5932)
Félix Malfaitdbaa787d191f
diff --git a/packages/twenty-website/src/app/_components/docs/AlgoliaDocSearch.tsx b/packages/twenty-website/src/app/_components/docs/AlgoliaDocSearch.tsxindex 17e2e1db621..160f4c15c5f 100644--- a/packages/twenty-website/src/app/_components/docs/AlgoliaDocSearch.tsx+++ b/packages/twenty-website/src/app/_components/docs/AlgoliaDocSearch.tsx@@ -47,8 +47,8 @@ export const AlgoliaDocSearch = ({ pathname }: AlgoliaDocSearchProps) => {</a></section>)}- appId={process.env.NEXT_PUBLIC_ALGOLIA_APP_ID as string}- apiKey={process.env.NEXT_PUBLIC_ALGOLIA_API_KEY as string}+ appId={process.env.NEXT_PUBLIC_ALGOLIA_APP_ID ?? ''}+ apiKey={process.env.NEXT_PUBLIC_ALGOLIA_API_KEY ?? ''}indexName={`twenty-${indexName}`}/>);diff --git a/packages/twenty-website/src/app/_components/docs/DocsCard.tsx b/packages/twenty-website/src/app/_components/docs/DocsCard.tsxindex 3c3164e0cfc..c5eeff85a28 100644--- a/packages/twenty-website/src/app/_components/docs/DocsCard.tsx+++ b/packages/twenty-website/src/app/_components/docs/DocsCard.tsx@@ -1,12 +1,14 @@'use client';import styled from '@emotion/styled';-import { usePathname, useRouter } from 'next/navigation';+import Link from 'next/link';+import { usePathname } from 'next/navigation';import { Theme } from '@/app/_components/ui/theme/theme';import { DocsArticlesProps } from '@/content/user-guide/constants/getDocsArticles';import { getCardPath } from '@/shared-utils/getCardPath';-const StyledContainer = styled.div`+const StyledContainer = styled(Link)`+ text-decoration: none;color: ${Theme.border.color.plain};border: 2px solid ${Theme.border.color.plain};border-radius: ${Theme.border.radius.md};@@ -58,13 +60,12 @@ export default function DocsCard({card: DocsArticlesProps;isSection?: boolean;}) {- const router = useRouter();const pathname = usePathname();const path = getCardPath(card, pathname, isSection);if (card.title) {return (- <StyledContainer onClick={() => router.push(path)}>+ <StyledContainer href={path}><StyledImage src={card.image} alt={card.title} /><StyledHeading>{card.title}</StyledHeading><StyledSubHeading>{card.info}</StyledSubHeading>diff --git a/packages/twenty-website/src/app/_components/docs/DocsContent.tsx b/packages/twenty-website/src/app/_components/docs/DocsContent.tsxindex eb46ee97a43..5d4c6c92603 100644--- a/packages/twenty-website/src/app/_components/docs/DocsContent.tsx+++ b/packages/twenty-website/src/app/_components/docs/DocsContent.tsx@@ -149,6 +149,7 @@ export default function DocsContent({ item }: { item: FileContent }) {style={{ objectFit: 'cover' }}onLoad={() => setImageLoaded(true)}loaded={imageLoaded.toString()}+ unoptimized/>)}</StyledImageContainer>diff --git a/packages/twenty-website/src/app/_components/playground/rest-api-wrapper.tsx b/packages/twenty-website/src/app/_components/playground/rest-api-wrapper.tsxnew file mode 100644index 00000000000..cd2da8ea8e6--- /dev/null+++ b/packages/twenty-website/src/app/_components/playground/rest-api-wrapper.tsx@@ -0,0 +1,29 @@+import React, { useEffect } from 'react';+// @ts-expect-error Migration loader as text not passing warnings+import { API } from '@stoplight/elements';++// @ts-expect-error Migration loader as text not passing warnings+import spotlightTheme from '!css-loader!@stoplight/elements/styles.min.css';++export const RestApiWrapper = ({ openApiJson }: { openApiJson: any }) => {+ // We load spotlightTheme style using useEffect as it breaks remaining docs style+ useEffect(() => {+ const styleElement = document.createElement('style');+ styleElement.innerHTML = spotlightTheme.toString();+ document.head.append(styleElement);++ return () => styleElement.remove();+ }, []);++ return (+ <div+ style={{+ height: 'calc(100vh - var(--ifm-navbar-height) - 45px)',+ width: '100%',+ overflow: 'auto',+ }}+ >+ <API apiDescriptionDocument={JSON.stringify(openApiJson)} router="hash" />+ </div>+ );+};diff --git a/packages/twenty-website/src/app/_components/ui/layout/PostImage.tsx b/packages/twenty-website/src/app/_components/ui/layout/PostImage.tsxindex b5bc150d7cb..00e215aa775 100644--- a/packages/twenty-website/src/app/_components/ui/layout/PostImage.tsx+++ b/packages/twenty-website/src/app/_components/ui/layout/PostImage.tsx@@ -1,5 +1,3 @@-import Image from 'next/image';-export const PostImage = ({sources,style,@@ -7,5 +5,5 @@ export const PostImage = ({sources: { light: string; dark: string };style?: React.CSSProperties;}) => {- return <Image src={sources.light} style={style} alt={sources.light} />;+ return <img src={sources.light} style={style} alt={sources.light} />;};diff --git a/packages/twenty-website/src/app/developers/[slug]/page.tsx b/packages/twenty-website/src/app/developers/[slug]/page.tsxindex 05cc57264ad..47efae71586 100644--- a/packages/twenty-website/src/app/developers/[slug]/page.tsx+++ b/packages/twenty-website/src/app/developers/[slug]/page.tsx@@ -5,8 +5,6 @@ import DocsContent from '@/app/_components/docs/DocsContent';import { fetchArticleFromSlug } from '@/shared-utils/fetchArticleFromSlug';import { formatSlug } from '@/shared-utils/formatSlug';-export const dynamic = 'force-dynamic';-export async function generateMetadata({params,}: {diff --git a/packages/twenty-website/src/app/developers/page.tsx b/packages/twenty-website/src/app/developers/page.tsxindex eb425f467bf..c2de5a6f7ad 100644--- a/packages/twenty-website/src/app/developers/page.tsx+++ b/packages/twenty-website/src/app/developers/page.tsx@@ -7,8 +7,6 @@ export const metadata = {icons: '/images/core/logo.svg',};-export const dynamic = 'force-dynamic';-export default async function DocsHome() {const filePath = 'src/content/developers/';const docsArticleCards = getDocsArticles(filePath);diff --git a/packages/twenty-website/src/app/developers/rest-api/core/page.tsx b/packages/twenty-website/src/app/developers/rest-api/core/page.tsxindex ae245a9959d..4c211c3ec4d 100644--- a/packages/twenty-website/src/app/developers/rest-api/core/page.tsx+++ b/packages/twenty-website/src/app/developers/rest-api/core/page.tsx@@ -1,40 +1,23 @@'use client';-import React, { useEffect, useState } from 'react';-// @ts-expect-error Migration loader as text not passing warnings-import { API } from '@stoplight/elements';++import { useEffect, useState } from 'react';import Playground from '@/app/_components/playground/playground';+import { RestApiWrapper } from '@/app/_components/playground/rest-api-wrapper';-// @ts-expect-error Migration loader as text not passing warnings-import spotlightTheme from '!css-loader!@stoplight/elements/styles.min.css';+const RestApi = () => {+ const [openApiJson, setOpenApiJson] = useState({});+ const [isClient, setIsClient] = useState(false);-const RestApiComponent = ({ openApiJson }: { openApiJson: any }) => {- // We load spotlightTheme style using useEffect as it breaks remaining docs styleuseEffect(() => {- const styleElement = document.createElement('style');- styleElement.innerHTML = spotlightTheme.toString();- document.head.append(styleElement);-- return () => styleElement.remove();+ setIsClient(true);}, []);- return (- <div- style={{- height: 'calc(100vh - var(--ifm-navbar-height) - 45px)',- width: '100%',- overflow: 'auto',- }}- >- <API apiDescriptionDocument={JSON.stringify(openApiJson)} router="hash" />- </div>- );-};--const restApi = () => {- const [openApiJson, setOpenApiJson] = useState({});+ if (!isClient) {+ return null;+ }- const children = <RestApiComponent openApiJson={openApiJson} />;+ const children = <RestApiWrapper openApiJson={openApiJson} />;return (<div style={{ width: '100vw' }}>@@ -47,4 +30,4 @@ const restApi = () => {);};-export default restApi;+export default RestApi;diff --git a/packages/twenty-website/src/app/developers/rest-api/metadata/page.tsx b/packages/twenty-website/src/app/developers/rest-api/metadata/page.tsxindex c49726892b9..e76cadc93b7 100644--- a/packages/twenty-website/src/app/developers/rest-api/metadata/page.tsx+++ b/packages/twenty-website/src/app/developers/rest-api/metadata/page.tsx@@ -1,39 +1,22 @@'use client';import React, { useEffect, useState } from 'react';-// @ts-expect-error Migration loader as text not passing warnings-import { API } from '@stoplight/elements';import Playground from '@/app/_components/playground/playground';+import { RestApiWrapper } from '@/app/_components/playground/rest-api-wrapper';-// @ts-expect-error Migration loader as text not passing warnings-import spotlightTheme from '!css-loader!@stoplight/elements/styles.min.css';+const restApi = () => {+ const [openApiJson, setOpenApiJson] = useState({});+ const [isClient, setIsClient] = useState(false);-const RestApiComponent = ({ openApiJson }: { openApiJson: any }) => {- // We load spotlightTheme style using useEffect as it breaks remaining docs styleuseEffect(() => {- const styleElement = document.createElement('style');- styleElement.innerHTML = spotlightTheme.toString();- document.head.append(styleElement);-- return () => styleElement.remove();+ setIsClient(true);}, []);- return (- <div- style={{- height: 'calc(100vh - var(--ifm-navbar-height) - 45px)',- overflow: 'auto',- }}- >- <API apiDescriptionDocument={JSON.stringify(openApiJson)} router="hash" />- </div>- );-};--const restApi = () => {- const [openApiJson, setOpenApiJson] = useState({});+ if (!isClient) {+ return null;+ }- const children = <RestApiComponent openApiJson={openApiJson} />;+ const children = <RestApiWrapper openApiJson={openApiJson} />;return (<Playgrounddiff --git a/packages/twenty-website/src/app/developers/section/[folder]/page.tsx b/packages/twenty-website/src/app/developers/section/[folder]/page.tsxindex 5879c5277a2..6e57de3bdc6 100644--- a/packages/twenty-website/src/app/developers/section/[folder]/page.tsx+++ b/packages/twenty-website/src/app/developers/section/[folder]/page.tsx@@ -6,8 +6,6 @@ import { getDocsArticles } from '@/content/user-guide/constants/getDocsArticles'import { fetchArticleFromSlug } from '@/shared-utils/fetchArticleFromSlug';import { formatSlug } from '@/shared-utils/formatSlug';-export const dynamic = 'force-dynamic';-export async function generateMetadata({params,}: {diff --git a/packages/twenty-website/src/app/user-guide/[slug]/page.tsx b/packages/twenty-website/src/app/user-guide/[slug]/page.tsxindex 3c33f602590..6c919639d5b 100644--- a/packages/twenty-website/src/app/user-guide/[slug]/page.tsx+++ b/packages/twenty-website/src/app/user-guide/[slug]/page.tsx@@ -5,8 +5,6 @@ import DocsContent from '@/app/_components/docs/DocsContent';import { fetchArticleFromSlug } from '@/shared-utils/fetchArticleFromSlug';import { formatSlug } from '@/shared-utils/formatSlug';-export const dynamic = 'force-dynamic';-export async function generateMetadata({params,}: {diff --git a/packages/twenty-website/src/app/user-guide/page.tsx b/packages/twenty-website/src/app/user-guide/page.tsxindex 308bd2fb2be..e23f4eb87a4 100644--- a/packages/twenty-website/src/app/user-guide/page.tsx+++ b/packages/twenty-website/src/app/user-guide/page.tsx@@ -8,8 +8,6 @@ export const metadata = {icons: '/images/core/logo.svg',};-export const dynamic = 'force-dynamic';-export default async function UserGuideHome() {const filePath = 'src/content/user-guide/';const docsArticleCards = getDocsArticles(filePath);diff --git a/packages/twenty-website/src/app/user-guide/section/[folder]/[documentation]/page.tsx b/packages/twenty-website/src/app/user-guide/section/[folder]/[documentation]/page.tsxindex c331f118e1e..4804aa7248c 100644--- a/packages/twenty-website/src/app/user-guide/section/[folder]/[documentation]/page.tsx+++ b/packages/twenty-website/src/app/user-guide/section/[folder]/[documentation]/page.tsx@@ -5,8 +5,6 @@ import DocsContent from '@/app/_components/docs/DocsContent';import { fetchArticleFromSlug } from '@/shared-utils/fetchArticleFromSlug';import { formatSlug } from '@/shared-utils/formatSlug';-export const dynamic = 'force-dynamic';-export async function generateMetadata({params,}: {diff --git a/packages/twenty-website/src/shared-utils/getCardPath.tsx b/packages/twenty-website/src/shared-utils/getCardPath.tsxindex f7cadc48ad2..6bb3d599c89 100644--- a/packages/twenty-website/src/shared-utils/getCardPath.tsx+++ b/packages/twenty-website/src/shared-utils/getCardPath.tsx@@ -16,7 +16,7 @@ export const getCardPath = (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}`;+ return `/developers/${apiType}/${apiName}`;} else if (card.fileName.includes('storybook')) {return 'https://storybook.twenty.com';} else if (card.fileName.includes('components')) {diff --git a/yarn.lock b/yarn.lockindex ce824dc233a..8c0943b0f8d 100644--- a/yarn.lock+++ b/yarn.lock@@ -22527,24 +22527,10 @@ __metadata:languageName: nodelinkType: hard-"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001538, caniuse-lite@npm:^1.0.30001565":- version: 1.0.30001568- resolution: "caniuse-lite@npm:1.0.30001568"- checksum: 13f01e5a2481134bd61cf565ce9fecbd8e107902927a0dcf534230a92191a81f1715792170f5f39719c767c3a96aa6df9917a8d5601f15bbd5e4041a8cfecc99- languageName: node- linkType: hard--"caniuse-lite@npm:^1.0.30001406":- version: 1.0.30001571- resolution: "caniuse-lite@npm:1.0.30001571"- checksum: 632f476e39febbfb5dc91c236981f3d518dc0cf55c42cc2bba431a6b6f4cceae3f9cd74d26312f30e9de65a3cc92ccf80d964ba8de061e25f37b7f0518303dad- languageName: node- linkType: hard--"caniuse-lite@npm:^1.0.30001587":- version: 1.0.30001589- resolution: "caniuse-lite@npm:1.0.30001589"- checksum: 20debfb949413f603011bc7dacaf050010778bc4f8632c86fafd1bd0c43180c95ae7c31f6c82348f6309e5e221934e327c3607a216e3f09640284acf78cd6d4d+"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001406, caniuse-lite@npm:^1.0.30001538, caniuse-lite@npm:^1.0.30001565, caniuse-lite@npm:^1.0.30001587":+ version: 1.0.30001636+ resolution: "caniuse-lite@npm:1.0.30001636"+ checksum: e5f965b4da7bae1531fd9f93477d015729ff9e3fa12670ead39a9e6cdc4c43e62c272d47857c5cc332e7b02d697cb3f2f965a1030870ac7476da60c2fc81ee94languageName: nodelinkType: hard