make separate component for pageContent
This commit is contained in:
@ -1,9 +1,9 @@
|
|||||||
import { graphql } from "@/gql";
|
import { graphql } from "@/gql";
|
||||||
import { GenericFragment } from "@/gql/graphql";
|
import { GenericFragment } from "@/gql/graphql";
|
||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { PageHeader } from "@/components/general/PageHeader";
|
import { PageHeader } from "@/components/general/PageHeader";
|
||||||
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
|
|
||||||
export const dynamicParams = false;
|
export const dynamicParams = false;
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ export default async function Page({ params }: { params: { url: string[] } }) {
|
|||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
<PageHeader heading={page.title} lead={page.lead} />
|
<PageHeader heading={page.title} lead={page.lead} />
|
||||||
<Blocks blocks={page.body} />
|
<PageContent blocks={page.body} />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
|
||||||
import { Breadcrumb } from "@/components/general/Breadcrumb";
|
import { Breadcrumb } from "@/components/general/Breadcrumb";
|
||||||
import { ImageFigure } from "@/components/general/Image";
|
import { ImageFigure } from "@/components/general/Image";
|
||||||
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
import { graphql } from "@/gql";
|
import { graphql } from "@/gql";
|
||||||
import { NewsFragment } from "@/gql/graphql";
|
import { NewsFragment } from "@/gql/graphql";
|
||||||
import { formatDate, formatExtendedDateTime } from "@/lib/date";
|
import { formatDate, formatExtendedDateTime } from "@/lib/date";
|
||||||
@ -71,9 +71,7 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
<section className="pageContent">
|
<PageContent blocks={news.body} />
|
||||||
<Blocks blocks={news.body} />
|
|
||||||
</section>
|
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
|
||||||
import { EventDetails } from "@/components/events/EventDetails";
|
import { EventDetails } from "@/components/events/EventDetails";
|
||||||
import { EventHeader } from "@/components/events/EventHeader";
|
import { EventHeader } from "@/components/events/EventHeader";
|
||||||
import { BgPig } from "@/components/general/BgPig";
|
import { BgPig } from "@/components/general/BgPig";
|
||||||
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
import { graphql } from "@/gql";
|
import { graphql } from "@/gql";
|
||||||
import { EventFragment } from "@/gql/graphql";
|
import { EventFragment } from "@/gql/graphql";
|
||||||
import { getEventPig } from "@/lib/event";
|
import { getEventPig } from "@/lib/event";
|
||||||
@ -55,9 +55,7 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
<EventHeader event={event} />
|
<EventHeader event={event} />
|
||||||
<EventDetails event={event} />
|
<EventDetails event={event} />
|
||||||
<section className="pageContent">
|
<PageContent blocks={event.body} />
|
||||||
<Blocks blocks={event.body} />
|
|
||||||
</section>
|
|
||||||
</main>
|
</main>
|
||||||
{eventPig && <BgPig type={eventPig} color="white" />}
|
{eventPig && <BgPig type={eventPig} color="white" />}
|
||||||
</>
|
</>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
|
||||||
import { Breadcrumb } from "@/components/general/Breadcrumb";
|
import { Breadcrumb } from "@/components/general/Breadcrumb";
|
||||||
import Icon from "@/components/general/Icon";
|
import Icon from "@/components/general/Icon";
|
||||||
import { Image } from "@/components/general/Image";
|
import { Image } from "@/components/general/Image";
|
||||||
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
import { graphql } from "@/gql";
|
import { graphql } from "@/gql";
|
||||||
import { AssociationFragment } from "@/gql/graphql";
|
import { AssociationFragment } from "@/gql/graphql";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
@ -73,9 +73,7 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
<section className="pageContent">
|
<PageContent blocks={association.body} />
|
||||||
<Blocks blocks={association.body} />
|
|
||||||
</section>
|
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@ import { graphql } from "@/gql";
|
|||||||
import { AssociationFragment, AssociationIndexFragment } from "@/gql/graphql";
|
import { AssociationFragment, AssociationIndexFragment } from "@/gql/graphql";
|
||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { AssociationList } from "@/components/associations/AssociationList";
|
import { AssociationList } from "@/components/associations/AssociationList";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { PageHeader } from "@/components/general/PageHeader";
|
import { PageHeader } from "@/components/general/PageHeader";
|
||||||
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
|
|
||||||
const AssociationIndexDefinition = graphql(`
|
const AssociationIndexDefinition = graphql(`
|
||||||
fragment AssociationIndex on AssociationIndex {
|
fragment AssociationIndex on AssociationIndex {
|
||||||
@ -60,7 +60,7 @@ export default async function Page() {
|
|||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
<PageHeader heading={index.title} lead={index.lead} />
|
<PageHeader heading={index.title} lead={index.lead} />
|
||||||
{index.body && <Blocks blocks={index.body} />}
|
{index.body && <PageContent blocks={index.body} />}
|
||||||
<AssociationList associations={associations} heading="Foreninger og utvalg" />
|
<AssociationList associations={associations} heading="Foreninger og utvalg" />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { graphql } from "@/gql";
|
import { graphql } from "@/gql";
|
||||||
import { ContactIndexFragment } from "@/gql/graphql";
|
import { ContactIndexFragment } from "@/gql/graphql";
|
||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
|
||||||
import { PageHeader } from "@/components/general/PageHeader";
|
import { PageHeader } from "@/components/general/PageHeader";
|
||||||
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
|
|
||||||
const ContactIndexDefinition = graphql(`
|
const ContactIndexDefinition = graphql(`
|
||||||
fragment ContactIndex on ContactIndex {
|
fragment ContactIndex on ContactIndex {
|
||||||
@ -32,7 +32,7 @@ export default async function Page() {
|
|||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
<PageHeader heading={index.title} lead={index.lead} />
|
<PageHeader heading={index.title} lead={index.lead} />
|
||||||
{index.body && <Blocks blocks={index.body} />}
|
{index.body && <PageContent blocks={index.body} />}
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
|
||||||
import { ImageSliderBlock } from "@/components/blocks/ImageSliderBlock";
|
import { ImageSliderBlock } from "@/components/blocks/ImageSliderBlock";
|
||||||
import { Breadcrumb } from "@/components/general/Breadcrumb";
|
import { Breadcrumb } from "@/components/general/Breadcrumb";
|
||||||
import { Image } from "@/components/general/Image";
|
import { Image } from "@/components/general/Image";
|
||||||
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
import { NeufMap } from "@/components/venues/NeufMap";
|
import { NeufMap } from "@/components/venues/NeufMap";
|
||||||
import { VenueInfo } from "@/components/venues/VenueInfo";
|
import { VenueInfo } from "@/components/venues/VenueInfo";
|
||||||
import { graphql } from "@/gql";
|
import { graphql } from "@/gql";
|
||||||
@ -107,7 +107,7 @@ export default async function Page({ params }: { params: { slug: string } }) {
|
|||||||
<Breadcrumb link="/utleie" text="Lokale" />
|
<Breadcrumb link="/utleie" text="Lokale" />
|
||||||
<h1 className="page-title">{venue.title}</h1>
|
<h1 className="page-title">{venue.title}</h1>
|
||||||
</div>
|
</div>
|
||||||
<Blocks blocks={venue.body} />
|
<PageContent blocks={venue.body} />
|
||||||
<VenueInfo venue={venue} />
|
<VenueInfo venue={venue} />
|
||||||
<NeufMap venueSlug={venue.slug} />
|
<NeufMap venueSlug={venue.slug} />
|
||||||
</main>
|
</main>
|
||||||
|
@ -3,7 +3,7 @@ import { VenueFragment, VenueIndexFragment } from "@/gql/graphql";
|
|||||||
import { getClient } from "@/app/client";
|
import { getClient } from "@/app/client";
|
||||||
import { VenueList } from "@/components/venues/VenueList";
|
import { VenueList } from "@/components/venues/VenueList";
|
||||||
import { PageHeader } from "@/components/general/PageHeader";
|
import { PageHeader } from "@/components/general/PageHeader";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
|
|
||||||
const VenueIndexDefinition = graphql(`
|
const VenueIndexDefinition = graphql(`
|
||||||
fragment VenueIndex on VenueIndex {
|
fragment VenueIndex on VenueIndex {
|
||||||
@ -64,7 +64,7 @@ export default async function Page() {
|
|||||||
return (
|
return (
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
<PageHeader heading={index.title} lead={index.lead} />
|
<PageHeader heading={index.title} lead={index.lead} />
|
||||||
<Blocks blocks={index.body} />
|
<PageContent blocks={index.body} />
|
||||||
<VenueList venues={venues} />
|
<VenueList venues={venues} />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
@ -4,7 +4,7 @@ import { getClient } from "@/app/client";
|
|||||||
import { VenueList } from "@/components/venues/VenueList";
|
import { VenueList } from "@/components/venues/VenueList";
|
||||||
import { PageHeader } from "@/components/general/PageHeader";
|
import { PageHeader } from "@/components/general/PageHeader";
|
||||||
import { BgPig } from "@/components/general/BgPig";
|
import { BgPig } from "@/components/general/BgPig";
|
||||||
import { Blocks } from "@/components/blocks/Blocks";
|
import { PageContent } from "@/components/general/PageContent";
|
||||||
|
|
||||||
const VenueRentalIndexDefinition = graphql(`
|
const VenueRentalIndexDefinition = graphql(`
|
||||||
fragment VenueRentalIndex on VenueRentalIndex {
|
fragment VenueRentalIndex on VenueRentalIndex {
|
||||||
@ -42,7 +42,7 @@ export default async function Page() {
|
|||||||
<>
|
<>
|
||||||
<main className="site-main" id="main">
|
<main className="site-main" id="main">
|
||||||
<PageHeader heading={index.title} lead={index.lead} />
|
<PageHeader heading={index.title} lead={index.lead} />
|
||||||
{index.body && <Blocks blocks={index.body} />}
|
{index.body && <PageContent blocks={index.body} />}
|
||||||
<VenueList venues={bookableVenues} heading="Våre lokaler" />
|
<VenueList venues={bookableVenues} heading="Våre lokaler" />
|
||||||
</main>
|
</main>
|
||||||
<BgPig type="key" />
|
<BgPig type="key" />
|
||||||
|
@ -13,14 +13,12 @@ import { ContactEntityBlock } from "./ContactEntityBlock";
|
|||||||
import { NeufAddressSectionBlock } from "./NeufAddressSectionBlock";
|
import { NeufAddressSectionBlock } from "./NeufAddressSectionBlock";
|
||||||
import { OpeningHoursSectionBlock } from "./OpeningHoursSectionBlock";
|
import { OpeningHoursSectionBlock } from "./OpeningHoursSectionBlock";
|
||||||
|
|
||||||
export const Blocks = ({ blocks }: any) => {
|
export const Blocks = ({ blocks, pageContent }: { blocks: any, pageContent?: boolean }) => {
|
||||||
const sections = blocks.filter(
|
const sections = blocks.filter(
|
||||||
(block: any) => block?.__typename === "PageSectionBlock"
|
(block: any) => block?.__typename === "PageSectionBlock"
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return blocks.map((block: any) => {
|
||||||
<div className="blockContent">
|
|
||||||
{blocks.map((block: any) => {
|
|
||||||
switch (block?.blockType) {
|
switch (block?.blockType) {
|
||||||
case "RichTextBlock":
|
case "RichTextBlock":
|
||||||
return <RichTextBlock block={block} />;
|
return <RichTextBlock block={block} />;
|
||||||
@ -32,7 +30,7 @@ export const Blocks = ({ blocks }: any) => {
|
|||||||
return <EmbedBlock block={block} />;
|
return <EmbedBlock block={block} />;
|
||||||
break;
|
break;
|
||||||
case "ImageSliderBlock":
|
case "ImageSliderBlock":
|
||||||
return <ImageSliderBlock block={block} />;
|
return <ImageSliderBlock block={block} pageContent />;
|
||||||
break;
|
break;
|
||||||
case "HorizontalRuleBlock":
|
case "HorizontalRuleBlock":
|
||||||
return <HorizontalRuleBlock block={block} />;
|
return <HorizontalRuleBlock block={block} />;
|
||||||
@ -74,7 +72,5 @@ export const Blocks = ({ blocks }: any) => {
|
|||||||
console.log("unsupported block", block);
|
console.log("unsupported block", block);
|
||||||
return <div>Unsupported block type {block?.blockType}</div>;
|
return <div>Unsupported block type {block?.blockType}</div>;
|
||||||
}
|
}
|
||||||
})}
|
});
|
||||||
</div>
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
@ -14,12 +14,14 @@ import "./swiper.scss";
|
|||||||
export const ImageSliderBlock = ({
|
export const ImageSliderBlock = ({
|
||||||
block,
|
block,
|
||||||
hero,
|
hero,
|
||||||
|
pageContent
|
||||||
}: {
|
}: {
|
||||||
block: ImageSliderBlockType | any;
|
block: ImageSliderBlockType | any;
|
||||||
hero?: boolean;
|
hero?: boolean;
|
||||||
|
pageContent?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className={styles.imageSliderBlock} data-hero={hero}>
|
<div className={styles.imageSliderBlock} data-hero={hero} data-pageContent={pageContent}>
|
||||||
<Swiper
|
<Swiper
|
||||||
pagination={{
|
pagination={{
|
||||||
type: "fraction",
|
type: "fraction",
|
||||||
|
@ -42,9 +42,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-pageContent]{
|
||||||
&:last-child {
|
&:last-child {
|
||||||
margin-bottom: calc(var(--spacing-section-bottom)*-1);
|
margin-bottom: calc(var(--spacing-section-bottom)*-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&[data-hero] {
|
&[data-hero] {
|
||||||
margin-top: calc(var(--spacing-sitepadding-block)* -2);
|
margin-top: calc(var(--spacing-sitepadding-block)* -2);
|
||||||
|
10
web/src/components/general/PageContent.tsx
Normal file
10
web/src/components/general/PageContent.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Blocks } from "@/components/blocks/Blocks";
|
||||||
|
import styles from './pageContent.module.scss';
|
||||||
|
|
||||||
|
export const PageContent = ({ blocks }: any) => {
|
||||||
|
return (
|
||||||
|
<div className={styles.pageContent}>
|
||||||
|
<Blocks blocks={blocks} pageContent />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
};
|
@ -52,10 +52,6 @@
|
|||||||
.accordionContent {
|
.accordionContent {
|
||||||
padding: var(--spacing-m) 0 var(--spacing-s);
|
padding: var(--spacing-m) 0 var(--spacing-s);
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
>div {
|
|
||||||
padding-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
|
3
web/src/components/general/pageContent.module.scss
Normal file
3
web/src/components/general/pageContent.module.scss
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.pageContent {
|
||||||
|
padding-bottom: var(--spacing-section-bottom);
|
||||||
|
}
|
Reference in New Issue
Block a user