Skip to content

Commit

Permalink
🚧 add footerComponent to magazine article (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
SvSven committed Sep 30, 2022
1 parent 34e2d44 commit fec1fe8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
45 changes: 27 additions & 18 deletions web/lib/queries/magazine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ import downloadableFileFields from './common/actions/linkSelectorFields'
import downloadableImageFields from './common/actions/linkSelectorFields'
import markDefs from './common/blockEditorMarks'

const footerComponentFields = `
title,
text[]{
...,
${markDefs},
},
"designOptions": {
"background": coalesce(background.title, 'White'),
"imagePosition": coalesce(imagePosition, 'left'),
},
"image": image{
...,
"extension": asset-> extension
},
"action": action[0]{
${linkSelectorFields},
${downloadableFileFields},
${downloadableImageFields},
},
`

const promotedmagazineTags = `"": *[_type == "magazineIndex" && _lang == $lang][0] {"magazineTags":promotedMagazineTags[]->title[$lang]}`
export const magazineQuery = /* groq */ `
*[_type == "magazine" && slug.current == $slug && _lang == $lang] {
Expand Down Expand Up @@ -35,6 +56,11 @@ export const magazineQuery = /* groq */ `
${pageContentFields}
},
${slugsForNewsAndMagazine('magazine')},
"footerComponent": *[_id == 'magazineIndex'][0]{
"data": footerComponent{
${footerComponentFields}
}
}
}`

export const magazineIndexQuery = /* groq */ `
Expand All @@ -48,23 +74,6 @@ export const magazineIndexQuery = /* groq */ `
backgroundImage,
"magazineTags":promotedMagazineTags[]->title[$lang],
"footerComponent": footerComponent{
title,
text[]{
...,
${markDefs},
},
"designOptions": {
"background": coalesce(background.title, 'White'),
"imagePosition": coalesce(imagePosition, 'left'),
},
"image": image{
...,
"extension": asset-> extension
},
"action": action[0]{
${linkSelectorFields},
${downloadableFileFields},
${downloadableImageFields},
},
${footerComponentFields}
}
}`
4 changes: 4 additions & 0 deletions web/pageComponents/pageTemplates/MagazinePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { metaTitleSuffix } from '../../languages'
import { PageContent } from './shared/SharedPageContent'
import { MagazinePageSchema } from '../../types/types'
import { SharedBanner } from './shared/SharedBanner'
import Teaser from '../topicPages/Teaser'

This comment has been minimized.

Copy link
@fernandolucchesi

fernandolucchesi Oct 3, 2022

Contributor

Maybe we should move the teaser component to the /shared folder now

This comment has been minimized.

Copy link
@SvSven

SvSven Oct 5, 2022

Author Contributor

Good point, have moved it 👍


const MagazinePageLayout = styled.main`
/* The neverending spacing story... If two sections with the same background colour
Expand Down Expand Up @@ -53,6 +54,8 @@ const MagazinePage = ({ data }: MagazinePageProps) => {
}
})

const { footerComponent } = data

const ogImage = data?.seoAndSome?.openGraphImage?.asset ? data?.seoAndSome?.openGraphImage : data?.heroImage?.image
return (
<>
Expand All @@ -79,6 +82,7 @@ const MagazinePage = ({ data }: MagazinePageProps) => {
/>
)}
<PageContent data={data} />
{footerComponent?.data && <Teaser data={footerComponent.data} />}
</MagazinePageLayout>
</>
)
Expand Down
3 changes: 3 additions & 0 deletions web/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ export type TopicPageSchema = PageSchemaV2

export type MagazinePageSchema = PageSchemaV2 & {
magazineTags?: string[]
footerComponent?: {
data?: TeaserData
}
}

export type LandingPageSchema = {
Expand Down

0 comments on commit fec1fe8

Please sign in to comment.