Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions starterkits/drupal/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import LandingPageFull from '@/app/_components/content/LandingPageFull';
import { graphql } from '@/types/__generated__';
import {
GetNodeByPathQuery,
GetNodeByPathQueryVariables,
NodeLandingPage,
NodePage,
} from '@/types/__generated__/graphql';
import {
Expand All @@ -10,6 +12,7 @@ import {
routeIsInternal,
} from '@/util/drupal/dataIsEntityType';
import query from '@/util/drupal/query';
import entityIsType from '@/util/entityIsType';
import { draftMode } from 'next/headers';
import { notFound } from 'next/navigation';
import BasicPageFull from '../_components/content/BasicPageFull';
Expand All @@ -25,6 +28,7 @@ const getNodeByPath = graphql(`
status
}
...BasicPageFragment
...LandingPageFragment
}
}
}
Expand All @@ -42,10 +46,18 @@ async function NodeFull({ params }: { params: { slug: string[] } }) {
if (
!!data &&
routeIsInternal(data.route) &&
entityExists<NodePage>(data.route.entity, 'NodePage') &&
(entityExists<NodePage>(data.route.entity, 'NodePage') ||
entityExists<NodeLandingPage>(data.route.entity, 'NodeLandingPage')) &&
canShowEntity(data.route.entity, isEnabled)
) {
return <BasicPageFull entity={data.route.entity} />;
return entityIsType<NodeLandingPage>(
data.route.entity,
'NodeLandingPage',
) ? (
<LandingPageFull entity={data.route.entity} />
) : (
<BasicPageFull entity={data.route.entity} />
);
} else {
notFound();
}
Expand Down
28 changes: 28 additions & 0 deletions starterkits/drupal/app/_components/content/LandingPageFull.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import mapParagraph from '@/app/_components/paragraphs/mapParagraph';
import Page from '@/source/04-templates/Page/Page';
import { FragmentType, getFragmentData, graphql } from '@/types/__generated__';

const LandingPageFragment = graphql(`
fragment LandingPageFragment on NodeLandingPage {
title
content {
__typename
...AllParagraphsFragment
}
}
`);

function LandingPageDetailPage(props: {
entity: FragmentType<typeof LandingPageFragment>;
}) {
const page = getFragmentData(LandingPageFragment, props.entity);

return (
<Page title={page.title}>
{page.content ? page.content.map(mapParagraph) : null}
</Page>
);
}

export default LandingPageDetailPage;
export { LandingPageFragment };
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import entityIsType from '@/util/entityIsType';
const AccordionItemParagraphFragment = graphql(`
fragment AccordionItemParagraphFragment on ParagraphAccordionItem {
id
accordionHeading
accordionBody {
accordionHeading: title
accordionBody: wysiwyg {
processed
}
}
Expand All @@ -15,7 +15,7 @@ const AccordionItemParagraphFragment = graphql(`
const AccordionParagraphFragment = graphql(`
fragment AccordionParagraphFragment on ParagraphAccordion {
id
accordionItems {
accordionItems: paragraphs {
__typename
...AccordionItemParagraphFragment
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const AllParagraphsFragment = graphql(`
}
...AccordionParagraphFragment
...BlockEmbedParagraphFragment
...CallToActionParagraphFragment
...CardParagraphFragment
...CardsParagraphFragment
...HeroParagraphFragment
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import CallToAction from '@/source/03-components/CallToAction/CallToAction';
import { FragmentType, getFragmentData, graphql } from '@/types/__generated__';

const CallToActionParagraphFragment = graphql(`
fragment CallToActionParagraphFragment on ParagraphCallToAction {
id
ctaTitle: title
ctaContent: wysiwyg {
processed
}
ctaLink: link {
title
url
}
}
`);

function CallToActionParagraph({
entity,
}: {
entity: FragmentType<typeof CallToActionParagraphFragment>;
}) {
const paragraph = getFragmentData(CallToActionParagraphFragment, entity);
return (
<CallToAction
heading={paragraph.ctaTitle}
body={paragraph.ctaContent}
button={{
label: paragraph.ctaLink?.title,
href: paragraph.ctaLink?.url,
}}
/>
);
}

export default CallToActionParagraph;
export { CallToActionParagraphFragment };
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const HeroParagraphFragment = graphql(`
fragment HeroParagraphFragment on ParagraphHero {
id
heroAlignment
heroBody {
heroBody: wysiwyg {
processed
}
heroHasOverlay
heroHeading
heroImage {
heroHeading: title
heroImage: mediaItem {
... on MediaImage {
id
name
Expand All @@ -23,7 +23,7 @@ const HeroParagraphFragment = graphql(`
}
}
}
heroLink {
heroLink: link {
title
url
}
Expand Down
31 changes: 21 additions & 10 deletions starterkits/drupal/types/__generated__/gql.ts

Large diffs are not rendered by default.

Loading