Skip to content

Commit 3831cf3

Browse files
add Summary section for Project_Page
1 parent 5ec43c1 commit 3831cf3

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
import PortableText, { PortableTextQuery, type PortableTextValue } from '@/components/ui/portable-text'
3+
4+
export const Summary_Query = `
5+
summary {
6+
${PortableTextQuery('heading')}
7+
${PortableTextQuery('paragraph')}
8+
},
9+
`
10+
11+
export type Props = {
12+
heading: PortableTextValue
13+
paragraph: PortableTextValue
14+
}
15+
16+
const { heading, paragraph } = Astro.props
17+
---
18+
19+
<section class="Summary">
20+
<PortableText value={heading} heading="h2" />
21+
<PortableText value={paragraph} />
22+
</section>
23+
24+
<style lang="scss">
25+
.Summary {
26+
padding: clamp(3rem, calc(4vw / 0.48), 5rem) 0;
27+
max-width: 38rem;
28+
margin: 0 auto;
29+
h2 {
30+
margin-bottom: clamp(1.5rem, calc(2vw / 0.48), 2rem);
31+
}
32+
}
33+
</style>

apps/astro/src/pages/realizacje/[slug].astro

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import metadataFetch from '@/utils/metadata.fetch'
55
import Breadcrumbs from '@/components/ui/Breadcrumbs.astro'
66
import Hero, { Hero_Query, type HeroProps } from '@/components/Projects/Project/Hero.astro'
77
import Gallery, { Gallery_Query, type Props as GalleryProps } from '@/components/Projects/Project/Gallery.astro'
8-
8+
import Summary, { Summary_Query, type Props as SummaryProps } from '@/components/Projects/Project/Summary.astro'
99
export const slugPrefix = '/realizacje/'
1010
1111
export async function getStaticPaths() {
@@ -21,11 +21,12 @@ export async function getStaticPaths() {
2121
2222
const { slug } = Astro.params
2323
24-
const page = await sanityFetch<{ name: string; hero: HeroProps; gallery: GalleryProps }>({
24+
const page = await sanityFetch<{ name: string; hero: HeroProps; summary: SummaryProps; gallery: GalleryProps }>({
2525
query: `
2626
*[_type == 'Project_Collection' && slug.current == $slug][0] {
2727
name,
2828
${Hero_Query}
29+
${Summary_Query}
2930
${Gallery_Query}
3031
}
3132
`,
@@ -44,5 +45,6 @@ const metadata = await metadataFetch('Project_Collection', `${slugPrefix}${slug}
4445
]}
4546
/>
4647
<Hero {...page.hero} />
47-
{page.gallery?.images.length > 0 && <Gallery {...page.gallery} />}
48+
{page?.summary && <Summary {...page.summary} />}
49+
{page?.gallery?.images.length > 0 && <Gallery {...page.gallery} />}
4850
</Layout>

apps/sanity/schema/collectionTypes/Project_Collection.tsx

+27
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ export default defineType({
8181
title: 'Data zakończenia projektu (opcjonalnie)',
8282
description: 'Jeśli to pole jest puste, projekt będzie traktowany jako w trakcie realizacji.'
8383
}),
84+
defineField({
85+
name: 'summary',
86+
type: 'object',
87+
title: 'Podsumowanie projektu (opcjonalne)',
88+
fields: [
89+
defineField({
90+
name: 'heading',
91+
type: 'Heading',
92+
title: 'Nagłówek',
93+
validation: Rule => Rule.required(),
94+
}),
95+
defineField({
96+
name: 'paragraph',
97+
type: 'PortableText',
98+
title: 'Paragraf',
99+
validation: Rule => Rule.required(),
100+
}),
101+
],
102+
options: {
103+
collapsible: true,
104+
collapsed: false,
105+
}
106+
}),
84107
defineField({
85108
name: 'gallery',
86109
type: 'object',
@@ -105,6 +128,10 @@ export default defineType({
105128
validation: Rule => Rule.required(),
106129
}),
107130
],
131+
options: {
132+
collapsible: true,
133+
collapsed: false,
134+
}
108135
}),
109136
defineField({
110137
name: 'seo',

0 commit comments

Comments
 (0)