From 766cf57e37b0f3bdcb66e1c0a25bb8c963a9a6a6 Mon Sep 17 00:00:00 2001 From: "marta.pancaldi" Date: Sun, 30 Jul 2023 13:56:35 +0200 Subject: [PATCH] feat: add Home intro content --- sanity/deskStructure.js | 8 +++ sanity/schema.ts | 2 + src/app/(public)/page.tsx | 26 ++++++++- src/components/organisms/home/Intro.tsx | 77 +++++++++++++++++++++++++ src/pages/api/home.ts | 17 ++++++ src/queries/homeContent.ts | 13 +++++ src/schemas/homeContent.ts | 50 ++++++++++++++++ src/types/HomeContent.ts | 11 ++++ 8 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 src/components/organisms/home/Intro.tsx create mode 100644 src/pages/api/home.ts create mode 100644 src/queries/homeContent.ts create mode 100644 src/schemas/homeContent.ts create mode 100644 src/types/HomeContent.ts diff --git a/sanity/deskStructure.js b/sanity/deskStructure.js index a8564fc..1e04817 100644 --- a/sanity/deskStructure.js +++ b/sanity/deskStructure.js @@ -39,4 +39,12 @@ export const customStructure = (S) => sharedSection.map((section) => S.documentTypeListItem(section)) ) ), + S.listItem() + .title('Single Pages') + .child( + S.editor() + .id('homeContent') + .schemaType('homeContent') + .documentId('homeContent') + ), ]); diff --git a/sanity/schema.ts b/sanity/schema.ts index f0258dd..9680a8c 100644 --- a/sanity/schema.ts +++ b/sanity/schema.ts @@ -1,5 +1,6 @@ import { type SchemaTypeDefinition } from 'sanity'; +import homeContent from '@/schemas/homeContent'; import randomFact from '@/schemas/randomFact'; import book from '../src/schemas/book'; @@ -17,6 +18,7 @@ import videoGame from '../src/schemas/videoGame'; export const schema: { types: SchemaTypeDefinition[] } = { types: [ book, + homeContent, job, language, podcast, diff --git a/src/app/(public)/page.tsx b/src/app/(public)/page.tsx index 0ea98da..287ae77 100644 --- a/src/app/(public)/page.tsx +++ b/src/app/(public)/page.tsx @@ -1,15 +1,37 @@ +import { PortableText } from '@portabletext/react'; import * as React from 'react'; +import Intro from '@/components/organisms/home/Intro'; import Seo from '@/components/Seo'; +import { homeContentQuery } from '@/queries/homeContent'; + +import { sanityClient } from '../../../sanity/lib/client'; + +import { HomeContent } from '@/types/HomeContent'; + +const getData = async () => { + const homeData: HomeContent[] = await sanityClient.fetch(homeContentQuery); + + return { + homeContent: homeData[0], + }; +}; + const HomePage = async () => { + const { homeContent } = await getData(); + return (
-
- Homepage :) +
+
+ +
+ +
diff --git a/src/components/organisms/home/Intro.tsx b/src/components/organisms/home/Intro.tsx new file mode 100644 index 0000000..1cb0589 --- /dev/null +++ b/src/components/organisms/home/Intro.tsx @@ -0,0 +1,77 @@ +import Image from 'next/image'; +import React from 'react'; + +const Intro = () => { + return ( + <> +

+ Hey there šŸ‘‹šŸ» I'm Marta, a software engineer based in Turin, Italy, and I + am currently working at + + Resourcify + + . +

+ +

+ I hold a MSc in Advanced Computer Science from the University of + Manchester, and have four years of experience at + + BJSS + + and + + Booking.com + + . +

+ +
+ My skill set embraces a range of programming languages, including Java, + Kotlin, Python, C# and TypeScript, as well as frontend frameworks such + as React and Angular. +
+ +
+ While I have a solid foundation in backend development, my heart truly + lies in the exciting realm of full-stack engineering. The thrill of + bringing together the best of both worlds, seamlessly integrating robust + server-side solutions with captivating user interfaces, is what drives + my passion for this craft. +
+ +
+ In my free time, Iā€™m a fiction writer, an avid bookworm, an oboist and + alto singer, and a travel photographer. +
+ + ); +}; + +export default Intro; diff --git a/src/pages/api/home.ts b/src/pages/api/home.ts new file mode 100644 index 0000000..d4ec10c --- /dev/null +++ b/src/pages/api/home.ts @@ -0,0 +1,17 @@ +import { NextApiRequest, NextApiResponse } from 'next'; + +import { homeContentQuery } from '@/queries/homeContent'; + +import { sanityClient } from '../../../sanity/lib/client'; + +import { HomeContent } from '@/types/HomeContent'; + +const homeApi = async (req: NextApiRequest, res: NextApiResponse) => { + const homeContent: HomeContent = await sanityClient.fetch(homeContentQuery); + + res.status(200).json({ + home: homeContent, + }); +}; + +export default homeApi; diff --git a/src/queries/homeContent.ts b/src/queries/homeContent.ts new file mode 100644 index 0000000..d61bb1b --- /dev/null +++ b/src/queries/homeContent.ts @@ -0,0 +1,13 @@ +import { groq } from 'next-sanity'; + +export const homeContentQuery = groq` +*[_type == "homeContent"] { + _id, + title, + threeLineSummary, + summary0, + summary1, + summary2, + summary3, + summary4, +}`; diff --git a/src/schemas/homeContent.ts b/src/schemas/homeContent.ts new file mode 100644 index 0000000..ce941da --- /dev/null +++ b/src/schemas/homeContent.ts @@ -0,0 +1,50 @@ +import { defineField, defineType } from 'sanity'; + +export default defineType({ + name: 'homeContent', + title: 'Home Content', + type: 'document', + fields: [ + defineField({ + name: 'title', + title: 'Title', + type: 'string', + }), + defineField({ + name: 'threeLineSummary', + title: '3-line Summary', + type: 'array', + of: [{ type: 'block' }], + }), + defineField({ + name: 'summary0', + title: 'Summary - 0', + type: 'text', + rows: 3, + }), + defineField({ + name: 'summary1', + title: 'Summary - 1', + type: 'text', + rows: 3, + }), + defineField({ + name: 'summary2', + title: 'Summary - 2', + type: 'text', + rows: 4, + }), + defineField({ + name: 'summary3', + title: 'Summary - 3', + type: 'text', + rows: 5, + }), + defineField({ + name: 'summary4', + title: 'Summary - 4', + type: 'array', + of: [{ type: 'block' }], + }), + ], +}); diff --git a/src/types/HomeContent.ts b/src/types/HomeContent.ts new file mode 100644 index 0000000..5bb1b98 --- /dev/null +++ b/src/types/HomeContent.ts @@ -0,0 +1,11 @@ +import { TypedObject } from '@portabletext/types'; + +export interface HomeContent { + title: string; + threeLineSummary: TypedObject; + summary0: string; + summary1: string; + summary2: string; + summary3: string; + summary4: TypedObject; +}