Skip to content

Commit

Permalink
move react markdown rendering to client component
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelSiidorow committed Jan 25, 2024
1 parent 548e74c commit 471c103
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 22 additions & 0 deletions web/app/[locale]/terms/Content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";

import ReactMarkdown from "react-markdown";

export const TermsContent = ({
terms,
gdpr,
}: {
terms: string;
gdpr: string;
}) => {
return (
<>
<ReactMarkdown className="prose prose-secondary dark:prose-invert">
{terms}
</ReactMarkdown>
<ReactMarkdown className="prose prose-secondary dark:prose-invert">
{gdpr}
</ReactMarkdown>
</>
);
};
5 changes: 2 additions & 3 deletions web/app/[locale]/terms/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ReactMarkdown from 'react-markdown';
import Link from 'next/link';

import { fetchAPI } from '@/lib/api';
import { StrapiBaseType } from '@/utils/models';
import { useRouter } from 'next/navigation';
import { getTranslation } from '@/utils/translationHelper';
import { TermsContent } from './Content';
export const dynamic = 'force-dynamic';
type Fields = StrapiBaseType<{
terms: string;
Expand Down Expand Up @@ -37,8 +37,7 @@ const Terms = async ({params: {locale}}: Props) => {
const router = useRouter();
return (
<div className="container max-w-3xl bg-secondary-50 dark:bg-secondary-800 mx-auto rounded shadow-md p-8">
<ReactMarkdown className='prose prose-secondary dark:prose-invert'>{content.attributes.terms}</ReactMarkdown>
<ReactMarkdown className="prose prose-secondary dark:prose-invert">{content.attributes.gdpr}</ReactMarkdown>
<TermsContent terms={content.attributes.terms} gdpr={content.attributes.gdpr} />
<div className='my-4'>
<Link onClick={goBack} className='underline text-primary-900 dark:text-primary-500' href="">
{translation.back}
Expand Down

0 comments on commit 471c103

Please sign in to comment.