Skip to content

Commit

Permalink
add Investments_Page schema and initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
milewskibogumil committed Nov 1, 2024
1 parent 734e087 commit 6c88ae1
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/astro/src/components/Components.astro
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export type ComponentsProps = Array<ComponentsMap[keyof typeof components]>
type Props = {
data: ComponentsProps
indexStart?: number
hasPreviousSections?: boolean
}
const { data, indexStart = 0 } = Astro.props
const { data, hasPreviousSections = false } = Astro.props
export const Components_Query = /* groq */ `
components[] {
Expand Down Expand Up @@ -87,6 +87,6 @@ export const Components_Query = /* groq */ `
data?.map((item, i) => {
const DynamicComponent = components[item._type] as any
if (!DynamicComponent) return null
return <DynamicComponent {...item} index={indexStart + i} />
return <DynamicComponent {...item} index={hasPreviousSections ? i + 1 : i} />
})
}
7 changes: 7 additions & 0 deletions apps/astro/src/components/Investments/Hero.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
---

<section class="Hero"></section>

<style lang="scss"></style>
26 changes: 26 additions & 0 deletions apps/astro/src/pages/inwestycje.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
import Layout from '@/src/layouts/Layout.astro'
import metadataFetch from '@/utils/metadata.fetch'
import sanityFetch from '@/utils/sanity.fetch'
import Breadcrumbs from '@/components/ui/Breadcrumbs.astro'
import Hero from '@/components/Investments/Hero.astro'
import Components, { Components_Query, type ComponentsProps } from '@/components/Components.astro'
const metadata = await metadataFetch('Investments_Page')
const data = await sanityFetch<{ name: string; slug: string; components: ComponentsProps }>({
query: `
*[_type == "Investments_Page"][0] {
"name": title,
"slug": slug.current,
${Components_Query}
}
`,
})
---

<Layout {...metadata}>
<Breadcrumbs data={[{ name: data.name, path: data.slug }]} />
<Hero />
<Components data={data.components} hasPreviousSections={true} />
</Layout>
61 changes: 61 additions & 0 deletions apps/sanity/schema/singleTypes/Investments_Page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { defineField, defineType } from "sanity"
import { defineSlugForDocument } from "../../utils/define-slug-for-document";

const name = 'Investments_Page';
const title = 'Inwestycje';
const slug = '/inwestycje';
const icon = () => '💰';

export default defineType({
name: name,
type: 'document',
title: title,
icon,
fields: [
...defineSlugForDocument({ slug }),
defineField({
name: 'hero',
type: 'object',
title: 'Sekcja Hero',
description: 'Sekcja Hero, to sekcja, która znajduje się na górze strony.',
fields: [
defineField({
name: 'heading',
type: 'Heading',
title: 'Nagłówek',
validation: Rule => Rule.required(),
}),
defineField({
name: 'paragraph',
type: 'PortableText',
title: 'Paragraf',
validation: Rule => Rule.required(),
}),
],
validation: Rule => Rule.required(),
}),
defineField({
name: 'components',
type: 'components',
title: 'Page Components',
}),
defineField({
name: 'seo',
type: 'seo',
title: 'SEO',
group: 'seo',
}),
],
groups: [
{
name: 'seo',
title: 'SEO',
},
],
preview: {
prepare: () => ({
title: title,
subtitle: slug
})
}
});
4 changes: 4 additions & 0 deletions apps/sanity/structure/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ export const structure: StructureResolver = (S) =>
S.divider(),
createSingleton(S, "Index_Page"),
createSingleton(S, "Projects_Page"),
createSingleton(S, "Investments_Page"),
createSingleton(S, "About_Page"),
createSingleton(S, "Contact_Page"),
S.divider(),
createSingleton(S, "PrivacyPolicy_Page"),
createSingleton(S, "NotFound_Page"),
S.divider(),
createCollection(S, "Investment_Collection"),
S.divider(),
createCollection(S, "Faq_Collection"),
])
1 change: 1 addition & 0 deletions apps/sanity/structure/internal-linkable-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
export const InternalLinkableTypes: { type: string }[] = [
{ type: 'Index_Page' },
{ type: 'Projects_Page' },
{ type: 'Investments_Page' },
{ type: 'About_Page' },
{ type: 'Contact_Page' },
{ type: 'PrivacyPolicy_Page' },
Expand Down
4 changes: 4 additions & 0 deletions apps/sanity/structure/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import redirects from '../schema/singleTypes/redirects';
import Index_Page from '../schema/singleTypes/Index_Page';
import Contact_Page from '../schema/singleTypes/Contact_Page';
import Projects_Page from '../schema/singleTypes/Projects_Page';
import Investments_Page from '../schema/singleTypes/Investments_Page';
import About_Page from '../schema/singleTypes/About_Page';
import PrivacyPolicy_Page from '../schema/singleTypes/PrivacyPolicy_Page';
import NotFound_Page from '../schema/singleTypes/NotFound_Page';
Expand All @@ -13,16 +14,19 @@ const singleTypes = [
redirects,
Index_Page,
Projects_Page,
Investments_Page,
About_Page,
Contact_Page,
PrivacyPolicy_Page,
NotFound_Page,
];

// Collections Types
import Investment_Collection from '../schema/collectionTypes/Investment_Collection';
import Faq_Collection from '../schema/collectionTypes/Faq_Collection';

const collectionTypes = [
Investment_Collection,
Faq_Collection,
];

Expand Down

0 comments on commit 6c88ae1

Please sign in to comment.