fix: content pages breaking during ssr on vercel
This commit is contained in:
23
apps/marketing/src/app/(marketing)/[content]/content.tsx
Normal file
23
apps/marketing/src/app/(marketing)/[content]/content.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import Image from 'next/image';
|
||||||
|
|
||||||
|
import type { DocumentTypes } from 'contentlayer/generated';
|
||||||
|
import type { MDXComponents } from 'mdx/types';
|
||||||
|
import { useMDXComponent } from 'next-contentlayer/hooks';
|
||||||
|
|
||||||
|
const mdxComponents: MDXComponents = {
|
||||||
|
MdxNextImage: (props: { width: number; height: number; alt?: string; src: string }) => (
|
||||||
|
<Image {...props} alt={props.alt ?? ''} />
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ContentPageContentProps = {
|
||||||
|
document: DocumentTypes;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ContentPageContent = ({ document }: ContentPageContentProps) => {
|
||||||
|
const MDXContent = useMDXComponent(document.body.code);
|
||||||
|
|
||||||
|
return <MDXContent components={mdxComponents} />;
|
||||||
|
};
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
import Image from 'next/image';
|
|
||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
|
|
||||||
import { allDocuments } from 'contentlayer/generated';
|
import { allDocuments } from 'contentlayer/generated';
|
||||||
import type { MDXComponents } from 'mdx/types';
|
|
||||||
import { useMDXComponent } from 'next-contentlayer/hooks';
|
|
||||||
|
|
||||||
import { setupI18nSSR } from '@documenso/lib/client-only/providers/i18n.server';
|
import { setupI18nSSR } from '@documenso/lib/client-only/providers/i18n.server';
|
||||||
|
|
||||||
|
import { ContentPageContent } from './content';
|
||||||
|
|
||||||
export const dynamic = 'force-dynamic';
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export const generateMetadata = ({ params }: { params: { content: string } }) => {
|
export const generateMetadata = ({ params }: { params: { content: string } }) => {
|
||||||
@@ -19,12 +18,6 @@ export const generateMetadata = ({ params }: { params: { content: string } }) =>
|
|||||||
return { title: document.title };
|
return { title: document.title };
|
||||||
};
|
};
|
||||||
|
|
||||||
const mdxComponents: MDXComponents = {
|
|
||||||
MdxNextImage: (props: { width: number; height: number; alt?: string; src: string }) => (
|
|
||||||
<Image {...props} alt={props.alt ?? ''} />
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic catch all page for the root level that checks for content layer documents.
|
* A generic catch all page for the root level that checks for content layer documents.
|
||||||
*
|
*
|
||||||
@@ -39,11 +32,9 @@ export default async function ContentPage({ params }: { params: { content: strin
|
|||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const MDXContent = useMDXComponent(post.body.code);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="prose dark:prose-invert mx-auto">
|
<article className="prose dark:prose-invert mx-auto">
|
||||||
<MDXContent components={mdxComponents} />
|
<ContentPageContent document={post} />
|
||||||
</article>
|
</article>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user