Skip to content

Commit

Permalink
Merge pull request #163 from nr2f1/register-patient-micro-data
Browse files Browse the repository at this point in the history
Register patient micro data
  • Loading branch information
pataruco authored Jan 20, 2025
2 parents 539d4d6 + 4d567ef commit 92df49f
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
82 changes: 81 additions & 1 deletion website/src/app/[lang]/register-a-patient/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,68 @@
import SupportBanner from '@components/support-banner';
import { getClient } from '@graphql/client';
import {
GetMetadataDocument,
type GetMetadataQuery,
} from '@graphql/queries/metadata/index.generated';
import { registerPatientPageMetadataId } from '@models/metadata';
import type { PagePropsWithLocale } from '@shared/types/page-with-locale-params';
import type { NextPage } from 'next';
import type { Metadata, NextPage } from 'next';
import type { Graph, MedicalStudy, WebPage, WithContext } from 'schema-dts';
import RegisterPageBody from './page-body';
import RegisterPageHeader from './page-header';

const { query } = getClient();

const Page: NextPage<PagePropsWithLocale> = async ({ params }) => {
const { lang } = await params;

const {
data: {
// @ts-ignore
htmlHeadMetadata: { title, description },
},
} = await query<GetMetadataQuery>({
query: GetMetadataDocument,
variables: {
locale: lang,
id: registerPatientPageMetadataId,
},
});

const medicalStudy: WithContext<MedicalStudy> = {
'@context': 'https://schema.org',
'@type': 'MedicalStudy',
name: title,
description,
potentialAction: [
{
'@type': 'RegisterAction',
target: `https://nr2f1.org/${lang}/register-patient`,
name: title,
},
],
};

const webPage: WithContext<WebPage> = {
'@context': 'https://schema.org',
'@type': 'WebPage',
url: `https://nr2f1.org/${lang}/register-a-patient`,
name: title,
inLanguage: lang,
};

const jsonLd: Graph = {
'@context': 'https://schema.org',
'@graph': [medicalStudy, webPage],
};

return (
<>
<script
type="application/ld+json"
// biome-ignore lint/security/noDangerouslySetInnerHtml: this is a safe usage
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
<RegisterPageHeader lang={lang} />
<RegisterPageBody lang={lang} />
<SupportBanner lang={lang} />
Expand All @@ -17,3 +71,29 @@ const Page: NextPage<PagePropsWithLocale> = async ({ params }) => {
};

export default Page;

export async function generateMetadata({
params,
}: PagePropsWithLocale): Promise<Metadata> {
const { lang } = await params;

const {
data: {
// @ts-ignore
htmlHeadMetadata: { title, description, keywords },
},
error,
} = await query<GetMetadataQuery>({
query: GetMetadataDocument,
variables: {
locale: lang,
id: registerPatientPageMetadataId,
},
});

return {
title: `NR2F1 Foundation | ${title}`,
description,
keywords,
};
}
4 changes: 1 addition & 3 deletions website/src/components/accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const Accordion: React.FC<AccordionProps> = ({ title, content }) => {
return (
<details className={styles.accordion}>
<summary>{title}</summary>
<div>
<p>{content}</p>
</div>
<div>{content}</div>
</details>
);
};
Expand Down
3 changes: 2 additions & 1 deletion website/src/graphql/queries/metadata/index.generated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ export type GetMetadataQueryVariables = Types.Exact<{
}>;


export type GetMetadataQuery = { __typename?: 'Query', htmlHeadMetadata?: { __typename?: 'HtmlHeadMetadata', title?: string | null, description?: string | null } | null };
export type GetMetadataQuery = { __typename?: 'Query', htmlHeadMetadata?: { __typename?: 'HtmlHeadMetadata', title?: string | null, description?: string | null, keywords?: string | null } | null };


export const GetMetadataDocument = gql`
query GetMetadata($id: String!, $locale: String) {
htmlHeadMetadata(id: $id, locale: $locale) {
title
description
keywords
}
}
`;
Expand Down
1 change: 1 addition & 0 deletions website/src/graphql/queries/metadata/index.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ query GetMetadata($id: String!, $locale: String) {
htmlHeadMetadata(id: $id, locale: $locale) {
title
description
keywords
}
}
1 change: 1 addition & 0 deletions website/src/models/metadata/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const homepageMetadataId = '4CqS9EKVc0euRhzQasESTR';
export const registerPatientPageMetadataId = 'EolZvaSlFMYGxwOjeHC0u';

0 comments on commit 92df49f

Please sign in to comment.