From 31fde512a6c4422e886b18d5039ca036849b9f98 Mon Sep 17 00:00:00 2001 From: Aleksandr Kudriavets <07aleks26@gmail.com> Date: Tue, 25 Oct 2022 00:30:15 +0300 Subject: [PATCH 1/7] Add DonationV2 --- components/DonationV1/index.ts | 3 ++ components/DonationV2/donationV2.tsx | 42 ++++++++++++++++++++++++++++ components/DonationV2/index.ts | 3 ++ pages/index.tsx | 10 ++++--- 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 components/DonationV1/index.ts create mode 100644 components/DonationV2/donationV2.tsx create mode 100644 components/DonationV2/index.ts diff --git a/components/DonationV1/index.ts b/components/DonationV1/index.ts new file mode 100644 index 0000000..13f4b8b --- /dev/null +++ b/components/DonationV1/index.ts @@ -0,0 +1,3 @@ +import DonationV1 from './donationV1'; + +export default DonationV1; diff --git a/components/DonationV2/donationV2.tsx b/components/DonationV2/donationV2.tsx new file mode 100644 index 0000000..829312a --- /dev/null +++ b/components/DonationV2/donationV2.tsx @@ -0,0 +1,42 @@ +export default function DonationV2() { + const imageUrl = 'https://source.unsplash.com/630x441/'; + return ( +
+
+

+ Поддержать сообщество +

+ +
+ + + + + +
+

+ В связи с тем, что Тhe Rolling Scopes - это некоммерческое + сообщество разработчиков, которые днём и ночью контрибьютят в него + свои силы и знания бесплатно и в своё свободное время, мы завели + «копилку» на разные нужды RS. Сказать «спасибо» можно здесь - + https://opencollective.com/rsschool +

+ + + Поддержать сообщество + +
+
+
+
+ ); +} diff --git a/components/DonationV2/index.ts b/components/DonationV2/index.ts new file mode 100644 index 0000000..e9b8df5 --- /dev/null +++ b/components/DonationV2/index.ts @@ -0,0 +1,3 @@ +import DonationV2 from './donationV2'; + +export default DonationV2; diff --git a/pages/index.tsx b/pages/index.tsx index 0bbf32d..b491e15 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,7 +1,8 @@ -import { usePreviewSubscription } from '../lib/sanity'; -import { getClient, overlayDrafts } from '../lib/sanity.server'; -import { socialNetworksListQuery } from '../lib/queries/social-network'; -import SocialNetworking from '../components/SocialNetworking'; +import { usePreviewSubscription } from '@/lib/sanity'; +import { getClient, overlayDrafts } from '@/lib/sanity.server'; +import { socialNetworksListQuery } from '@/lib/queries/social-network'; +import SocialNetworking from '@/components/SocialNetworking'; +import DonationV2 from '@/components/DonationV2'; import { SocialNetworkingListT } from '../types'; export default function Index({ @@ -19,6 +20,7 @@ export default function Index({ return ( <> + ); } From 9bc849d754e77d47ce3426cc6ee801db9939bf49 Mon Sep 17 00:00:00 2001 From: Aleksandr Kudriavets <07aleks26@gmail.com> Date: Tue, 25 Oct 2022 00:31:32 +0300 Subject: [PATCH 2/7] Fix format --- components/DonationV2/donationV2.tsx | 16 ++++++++-------- components/Footer/footer.tsx | 5 +---- pages/api/revalidate.ts | 14 +++++++------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/components/DonationV2/donationV2.tsx b/components/DonationV2/donationV2.tsx index 829312a..b12a2be 100644 --- a/components/DonationV2/donationV2.tsx +++ b/components/DonationV2/donationV2.tsx @@ -8,14 +8,14 @@ export default function DonationV2() {
- - - - + + + +

diff --git a/components/Footer/footer.tsx b/components/Footer/footer.tsx index a6937d6..6dbb228 100644 --- a/components/Footer/footer.tsx +++ b/components/Footer/footer.tsx @@ -1,6 +1,3 @@ export default function Footer() { - return ( -

-
- ); + return
; } diff --git a/pages/api/revalidate.ts b/pages/api/revalidate.ts index 06edc04..ddd293f 100644 --- a/pages/api/revalidate.ts +++ b/pages/api/revalidate.ts @@ -26,7 +26,7 @@ const getQueryForType = type => { }; const log = (msg: string, error?: boolean) => - console[error ? 'error' : 'log'](`[revalidate] ${msg}`); + console[error ? 'error' : 'log'](`[revalidate] ${msg}`); async function readBody(readable) { const chunks = []; @@ -41,11 +41,11 @@ export default async function revalidate(req, res) { const signature = req.headers[SIGNATURE_HEADER_NAME]; const body = await readBody(req); // Read the body into a string if ( - !isValidSignature( - body, - signature, - process.env.SANITY_REVALIDATE_SECRET?.trim() - ) + !isValidSignature( + body, + signature, + process.env.SANITY_REVALIDATE_SECRET?.trim() + ) ) { const invalidSignature = 'Invalid signature'; log(invalidSignature, true); @@ -63,7 +63,7 @@ export default async function revalidate(req, res) { log(`Querying post slug for _id '${id}', type '${_type}' ..`); const slug = await sanityClient.fetch(getQueryForType(_type), { id }); const slugs = (Array.isArray(slug) ? slug : [slug]).map( - _slug => `/posts/${_slug}` + _slug => `/posts/${_slug}` ); const staleRoutes = ['/', ...slugs]; From 83b32c489750d1d247cb2dfa74607742ce091ae9 Mon Sep 17 00:00:00 2001 From: Aleksandr Kudriavets <07aleks26@gmail.com> Date: Wed, 26 Oct 2022 23:11:56 +0300 Subject: [PATCH 3/7] Fix comment from review, add community, speakers --- README.md | 14 +++---- components/Community/community.tsx | 31 ++++++++++++++ components/Community/index.ts | 3 ++ components/Community/styles.module.scss | 35 ++++++++++++++++ components/DonationV1/donation-v1.tsx | 21 ++++++++++ components/DonationV1/donationV1.tsx | 23 ---------- components/DonationV1/index.ts | 2 +- components/DonationV1/styles.module.scss | 21 ++++++++++ components/DonationV2/donation-v2.tsx | 36 ++++++++++++++++ components/DonationV2/donationV2.tsx | 42 ------------------- components/DonationV2/index.ts | 2 +- components/DonationV2/styles.module.scss | 35 ++++++++++++++++ components/Speakers/index.ts | 3 ++ components/Speakers/speakers.tsx | 21 ++++++++++ components/Speakers/styles.module.scss | 21 ++++++++++ lib/queries/community.js | 13 ++++++ lib/queries/donation-v1.js | 13 ++++++ lib/queries/donation-v2.js | 14 +++++++ lib/{queries.js => queries/examples.js} | 0 lib/queries/index.js | 15 +++++++ lib/queries/social-network.js | 2 +- lib/queries/speakers.js | 13 ++++++ pages/index.tsx | 53 +++++++++++++++++++++--- studio/schemas/community.js | 27 ++++++++++++ studio/schemas/donation-v1.js | 32 ++++++++++++++ studio/schemas/donation-v2.js | 39 +++++++++++++++++ studio/schemas/schema.js | 10 ++++- studio/schemas/speakers.js | 32 ++++++++++++++ types/index.ts | 24 +++++++++++ 29 files changed, 515 insertions(+), 82 deletions(-) create mode 100644 components/Community/community.tsx create mode 100644 components/Community/index.ts create mode 100644 components/Community/styles.module.scss create mode 100644 components/DonationV1/donation-v1.tsx delete mode 100644 components/DonationV1/donationV1.tsx create mode 100644 components/DonationV1/styles.module.scss create mode 100644 components/DonationV2/donation-v2.tsx delete mode 100644 components/DonationV2/donationV2.tsx create mode 100644 components/DonationV2/styles.module.scss create mode 100644 components/Speakers/index.ts create mode 100644 components/Speakers/speakers.tsx create mode 100644 components/Speakers/styles.module.scss create mode 100644 lib/queries/community.js create mode 100644 lib/queries/donation-v1.js create mode 100644 lib/queries/donation-v2.js rename lib/{queries.js => queries/examples.js} (100%) create mode 100644 lib/queries/index.js create mode 100644 lib/queries/speakers.js create mode 100644 studio/schemas/community.js create mode 100644 studio/schemas/donation-v1.js create mode 100644 studio/schemas/donation-v2.js create mode 100644 studio/schemas/speakers.js diff --git a/README.md b/README.md index e5d4784..5f4d6c6 100644 --- a/README.md +++ b/README.md @@ -65,13 +65,13 @@ Then set these variables in `.env.local`: - `NEXT_PUBLIC_SANITY_PROJECT_ID` should be the `projectId` value from [`sanity.json`]. - `NEXT_PUBLIC_SANITY_DATASET` should be the `dataset` value from [`sanity.json`]. - `SANITY_API_READ_TOKEN` create an API token with `read-only` permissions: - - Run this to open your project settings or go to https://manage.sanity.io/ and open your project: - ```bash - (cd studio && npx @sanity/cli manage) - ``` - - Go to **API** and the **Tokens** section at the bottom, launch its **Add API token** button. - - Name it `SANITY_API_READ_TOKEN`, set **Permissions** to `Viewer`. - - Hit **Save** and you can copy/paste the token. + - Run this to open your project settings or go to https://manage.sanity.io/ and open your project: + ```bash + (cd studio && npx @sanity/cli manage) + ``` + - Go to **API** and the **Tokens** section at the bottom, launch its **Add API token** button. + - Name it `SANITY_API_READ_TOKEN`, set **Permissions** to `Viewer`. + - Hit **Save** and you can copy/paste the token. Your `.env.local` file should look like this: diff --git a/components/Community/community.tsx b/components/Community/community.tsx new file mode 100644 index 0000000..1d0557c --- /dev/null +++ b/components/Community/community.tsx @@ -0,0 +1,31 @@ +import Image from 'next/image'; +import { urlForImage } from '@/lib/sanity'; +import { CommunityT } from 'types'; +import styles from './styles.module.scss'; + +type Props = { + community: CommunityT; +} + +export default function Community({ community }: Props) { + const imageUrl = community.picture?.asset?._ref + ? urlForImage(community.picture).url() + : 'https://source.unsplash.com/630x441/'; + return ( +
+
+ +
+
+ +
+ +
+

{community.title}

+

+
+
+
+
+ ); +} diff --git a/components/Community/index.ts b/components/Community/index.ts new file mode 100644 index 0000000..e16d7f7 --- /dev/null +++ b/components/Community/index.ts @@ -0,0 +1,3 @@ +import Community from './community'; + +export default Community; diff --git a/components/Community/styles.module.scss b/components/Community/styles.module.scss new file mode 100644 index 0000000..39477d2 --- /dev/null +++ b/components/Community/styles.module.scss @@ -0,0 +1,35 @@ +.block { + @apply container px-20 py-20 mx-auto; +} + +.content { + @apply lg:-mx-6 lg:flex; +} + +.right { + @apply lg:w-1/2; +} + +.title { + @apply text-3xl font-bold; + color: #1A1A1A; +} + +.description { + @apply mt-3 text-sm md:text-sm; + color: #1A1A1A; +} + +.link { + @apply inline-flex justify-center text-sm font-semibold py-2.5 px-4 text-white mt-6; + background-color: #191B1D; +} + +.image { + @apply w-full h-72 lg:h-80 lg:mr-32 lg:w-1/2; + position: relative; + + & > span > img { + @apply object-cover; + } +} \ No newline at end of file diff --git a/components/DonationV1/donation-v1.tsx b/components/DonationV1/donation-v1.tsx new file mode 100644 index 0000000..c9ccf47 --- /dev/null +++ b/components/DonationV1/donation-v1.tsx @@ -0,0 +1,21 @@ +import Link from 'next/link'; +import { DonationV1T } from 'types'; +import styles from './styles.module.scss'; + +type Props = { + donation: DonationV1T; +} + +export default function DonationV1({ donation }: Props) { + return ( +
+
+

{donation.title}

+ {donation.description} + + {donation.titleLink} + +
+
+ ); +} diff --git a/components/DonationV1/donationV1.tsx b/components/DonationV1/donationV1.tsx deleted file mode 100644 index 57c83ef..0000000 --- a/components/DonationV1/donationV1.tsx +++ /dev/null @@ -1,23 +0,0 @@ -export default function DonationV1() { - return ( -
-
-

- Donation for RS School -

- - Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut - labore et dolore magna aliquat enim eiusmod tempor ad minim - - - Make a donation - -
-
- ); -} diff --git a/components/DonationV1/index.ts b/components/DonationV1/index.ts index 13f4b8b..00f85db 100644 --- a/components/DonationV1/index.ts +++ b/components/DonationV1/index.ts @@ -1,3 +1,3 @@ -import DonationV1 from './donationV1'; +import DonationV1 from './donation-v1'; export default DonationV1; diff --git a/components/DonationV1/styles.module.scss b/components/DonationV1/styles.module.scss new file mode 100644 index 0000000..9ee3552 --- /dev/null +++ b/components/DonationV1/styles.module.scss @@ -0,0 +1,21 @@ +.block { + @apply flex flex-col justify-center h-80 text-center px-8 dark:text-white; + background-color: #191b1d; +} + +.container { + @apply flex flex-col justify-center items-center mx-auto md:max-w-[50%]; +} + +.title { + @apply text-slate-900 text-4xl tracking-tight font-extrabold sm:text-5xl dark:text-white; +} + +.description { + @apply mt-6 text-base; +} + +.link { + @apply inline-flex justify-center text-sm font-semibold py-2.5 px-4 bg-white mt-6 ml-8; + color: #191B1D; +} \ No newline at end of file diff --git a/components/DonationV2/donation-v2.tsx b/components/DonationV2/donation-v2.tsx new file mode 100644 index 0000000..1b8a020 --- /dev/null +++ b/components/DonationV2/donation-v2.tsx @@ -0,0 +1,36 @@ +import Link from 'next/link'; +import Image from 'next/image'; +import { urlForImage } from '@/lib/sanity'; +import { DonationV2T } from 'types'; +import styles from './styles.module.scss'; + +type Props = { + donation: DonationV2T; +} + +export default function DonationV2({ donation }: Props) { + const imageUrl = donation.picture?.asset?._ref + ? urlForImage(donation.picture).url() + : 'https://source.unsplash.com/630x441/'; + return ( +
+
+

{donation.title}

+ +
+
+ +
+ +
+

{donation.description}

+ + + {donation.titleLink} + +
+
+
+
+ ); +} diff --git a/components/DonationV2/donationV2.tsx b/components/DonationV2/donationV2.tsx deleted file mode 100644 index b12a2be..0000000 --- a/components/DonationV2/donationV2.tsx +++ /dev/null @@ -1,42 +0,0 @@ -export default function DonationV2() { - const imageUrl = 'https://source.unsplash.com/630x441/'; - return ( -
-
-

- Поддержать сообщество -

- -
- - - - - -
-

- В связи с тем, что Тhe Rolling Scopes - это некоммерческое - сообщество разработчиков, которые днём и ночью контрибьютят в него - свои силы и знания бесплатно и в своё свободное время, мы завели - «копилку» на разные нужды RS. Сказать «спасибо» можно здесь - - https://opencollective.com/rsschool -

- - - Поддержать сообщество - -
-
-
-
- ); -} diff --git a/components/DonationV2/index.ts b/components/DonationV2/index.ts index e9b8df5..e90c3e8 100644 --- a/components/DonationV2/index.ts +++ b/components/DonationV2/index.ts @@ -1,3 +1,3 @@ -import DonationV2 from './donationV2'; +import DonationV2 from './donation-v2'; export default DonationV2; diff --git a/components/DonationV2/styles.module.scss b/components/DonationV2/styles.module.scss new file mode 100644 index 0000000..1fd0ca6 --- /dev/null +++ b/components/DonationV2/styles.module.scss @@ -0,0 +1,35 @@ +.block { + @apply container px-6 py-10 mx-auto; +} + +.content { + @apply mt-8 lg:-mx-6 lg:flex lg:items-center; +} + +.right { + @apply mt-6 lg:w-1/2 lg:mt-auto; +} + +.title { + @apply text-3xl font-bold; + color: #1A1A1A; +} + +.description { + @apply mt-3 text-sm md:text-sm; + color: #1A1A1A; +} + +.link { + @apply inline-flex justify-center text-sm font-semibold py-2.5 px-4 text-white mt-6; + background-color: #191B1D; +} + +.image { + @apply w-full h-72 lg:h-96 lg:mx-6 lg:w-1/2; + position: relative; + + & > span > img { + @apply object-cover; + } +} \ No newline at end of file diff --git a/components/Speakers/index.ts b/components/Speakers/index.ts new file mode 100644 index 0000000..aef43d7 --- /dev/null +++ b/components/Speakers/index.ts @@ -0,0 +1,3 @@ +import Speakers from './speakers'; + +export default Speakers; diff --git a/components/Speakers/speakers.tsx b/components/Speakers/speakers.tsx new file mode 100644 index 0000000..6195f62 --- /dev/null +++ b/components/Speakers/speakers.tsx @@ -0,0 +1,21 @@ +import Link from 'next/link'; +import { SpeakersT } from 'types'; +import styles from './styles.module.scss'; + +type Props = { + speaker: SpeakersT; +} + +export default function Speakers({ speaker }: Props) { + return ( +
+
+

{speaker.title}

+ {speaker.description} + + {speaker.titleLink} + +
+
+ ); +} diff --git a/components/Speakers/styles.module.scss b/components/Speakers/styles.module.scss new file mode 100644 index 0000000..9ee3552 --- /dev/null +++ b/components/Speakers/styles.module.scss @@ -0,0 +1,21 @@ +.block { + @apply flex flex-col justify-center h-80 text-center px-8 dark:text-white; + background-color: #191b1d; +} + +.container { + @apply flex flex-col justify-center items-center mx-auto md:max-w-[50%]; +} + +.title { + @apply text-slate-900 text-4xl tracking-tight font-extrabold sm:text-5xl dark:text-white; +} + +.description { + @apply mt-6 text-base; +} + +.link { + @apply inline-flex justify-center text-sm font-semibold py-2.5 px-4 bg-white mt-6 ml-8; + color: #191B1D; +} \ No newline at end of file diff --git a/lib/queries/community.js b/lib/queries/community.js new file mode 100644 index 0000000..bf6b944 --- /dev/null +++ b/lib/queries/community.js @@ -0,0 +1,13 @@ +import { groq } from 'next-sanity'; + +const communityItem = ` +_id, +title, +description, +picture +`; + +export const communityQuery = groq`*[_type == "community"][]{${communityItem}}`; + +export default communityQuery + diff --git a/lib/queries/donation-v1.js b/lib/queries/donation-v1.js new file mode 100644 index 0000000..b4212ac --- /dev/null +++ b/lib/queries/donation-v1.js @@ -0,0 +1,13 @@ +import { groq } from 'next-sanity'; + +const donationItem = ` +_id, +title, +description, +titleLink, +link +`; + +export const donationV1Query = groq`*[_type == "donation-v1"][]{${donationItem}}`; + +export default donationV1Query; diff --git a/lib/queries/donation-v2.js b/lib/queries/donation-v2.js new file mode 100644 index 0000000..3a4d9c0 --- /dev/null +++ b/lib/queries/donation-v2.js @@ -0,0 +1,14 @@ +import { groq } from 'next-sanity'; + +const donationItem = ` +_id, +title, +description, +titleLink, +link, +picture +`; + +export const donationV2Query = groq`*[_type == "donation-v2"][]{${donationItem}}`; + +export default donationV2Query; diff --git a/lib/queries.js b/lib/queries/examples.js similarity index 100% rename from lib/queries.js rename to lib/queries/examples.js diff --git a/lib/queries/index.js b/lib/queries/index.js new file mode 100644 index 0000000..7febee5 --- /dev/null +++ b/lib/queries/index.js @@ -0,0 +1,15 @@ +import community from './community'; +import donationV1 from './donation-v1'; +import donationV2 from './donation-v2'; +import speakers from './speakers'; +import socialNetworksList from './social-network'; + +const queries = { + community, + donationV1, + donationV2, + socialNetworksList, + speakers +} + +export default queries; \ No newline at end of file diff --git a/lib/queries/social-network.js b/lib/queries/social-network.js index 461df3a..2ba530f 100644 --- a/lib/queries/social-network.js +++ b/lib/queries/social-network.js @@ -8,4 +8,4 @@ social_item_link export const socialNetworksListQuery = groq`*[_type == "social_link"][]{${socialItem}}`; -export const test = 'test'; +export default socialNetworksListQuery; diff --git a/lib/queries/speakers.js b/lib/queries/speakers.js new file mode 100644 index 0000000..3b5aa02 --- /dev/null +++ b/lib/queries/speakers.js @@ -0,0 +1,13 @@ +import { groq } from 'next-sanity'; + +const speakersItem = ` +_id, +title, +description, +titleLink, +link +`; + +export const speakersQuery = groq`*[_type == "speakers"][]{${speakersItem}}`; + +export default speakersQuery; diff --git a/pages/index.tsx b/pages/index.tsx index b491e15..89f877f 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,37 +1,78 @@ import { usePreviewSubscription } from '@/lib/sanity'; import { getClient, overlayDrafts } from '@/lib/sanity.server'; -import { socialNetworksListQuery } from '@/lib/queries/social-network'; +import queries from '@/lib/queries'; import SocialNetworking from '@/components/SocialNetworking'; import DonationV2 from '@/components/DonationV2'; -import { SocialNetworkingListT } from '../types'; +import DonationV1 from '@/components/DonationV1'; +import Speakers from '@/components/Speakers'; +import Community from '@/components/Community'; +import { CommunityT, DonationV1T, DonationV2T, SocialNetworkingListT, SpeakersT } from '../types'; export default function Index({ socialNetworksList: initialSocialNetworksList, + donationV1: initialDonationV1, + donationV2: initialDonationV2, + speakers: initialSpeakers, + community: initialCommunity, preview }) { + const { data: allDonationV1 } = usePreviewSubscription(queries.donationV1, { + initialData: initialDonationV1, + enabled: preview + }); + const { data: allDonationV2 } = usePreviewSubscription(queries.donationV1, { + initialData: initialDonationV2, + enabled: preview + }); + const { data: allCommunity } = usePreviewSubscription(queries.donationV1, { + initialData: initialCommunity, + enabled: preview + }); const { data: allSocialList } = usePreviewSubscription( - socialNetworksListQuery, + queries.socialNetworksList, { initialData: initialSocialNetworksList, enabled: preview } ); + const { data: allSpeakers } = usePreviewSubscription( + queries.speakers, + { + initialData: initialSpeakers, + enabled: preview + } + ); return ( <> - + + + + ); } export async function getStaticProps({ preview = false }) { const socialNetworksList = overlayDrafts( - await getClient(preview).fetch(socialNetworksListQuery) + await getClient(preview).fetch(queries.socialNetworksList) + ); + const donationV1 = overlayDrafts( + await getClient(preview).fetch(queries.donationV1) + ); + const donationV2 = overlayDrafts( + await getClient(preview).fetch(queries.donationV2) + ); + const speakers = overlayDrafts( + await getClient(preview).fetch(queries.speakers) + ); + const community = overlayDrafts( + await getClient(preview).fetch(queries.community) ); return { - props: { socialNetworksList, preview }, + props: { socialNetworksList, donationV1, donationV2, speakers, community, preview }, // If webhooks isn't setup then attempt to re-generate in 1 minute intervals revalidate: process.env.SANITY_REVALIDATE_SECRET ? undefined : 60 }; diff --git a/studio/schemas/community.js b/studio/schemas/community.js new file mode 100644 index 0000000..fd54a6f --- /dev/null +++ b/studio/schemas/community.js @@ -0,0 +1,27 @@ +export default { + name: 'community', + title: 'Community', + type: 'document', + fields: [ + { + name: 'title', + title: 'Title', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'description', + title: 'Description', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'picture', + title: 'Picture', + type: 'image', + options: { hotspot: true }, + validation: Rule => Rule.required() + } + ] + }; + \ No newline at end of file diff --git a/studio/schemas/donation-v1.js b/studio/schemas/donation-v1.js new file mode 100644 index 0000000..6577560 --- /dev/null +++ b/studio/schemas/donation-v1.js @@ -0,0 +1,32 @@ +export default { + name: 'donation-v1', + title: 'Donation-v1', + type: 'document', + fields: [ + { + name: 'title', + title: 'Title', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'description', + title: 'Description', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'titleLink', + title: 'Title Link', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'link', + title: 'Url', + type: 'url', + validation: Rule => Rule.required() + } + ] + }; + \ No newline at end of file diff --git a/studio/schemas/donation-v2.js b/studio/schemas/donation-v2.js new file mode 100644 index 0000000..274d749 --- /dev/null +++ b/studio/schemas/donation-v2.js @@ -0,0 +1,39 @@ +export default { + name: 'donation-v2', + title: 'Donation-v2', + type: 'document', + fields: [ + { + name: 'title', + title: 'Title', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'description', + title: 'Description', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'titleLink', + title: 'Title Link', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'link', + title: 'Url', + type: 'url', + validation: Rule => Rule.required() + }, + { + name: 'picture', + title: 'Picture', + type: 'image', + options: { hotspot: true }, + validation: Rule => Rule.required() + } + ] + }; + \ No newline at end of file diff --git a/studio/schemas/schema.js b/studio/schemas/schema.js index 1687400..48180e4 100644 --- a/studio/schemas/schema.js +++ b/studio/schemas/schema.js @@ -11,6 +11,10 @@ import schemaTypes from 'all:part:@sanity/base/schema-type'; import post from './post'; import author from './author'; import socialLink from './social-link'; +import donationV1 from './donation-v1'; +import donationV2 from './donation-v2'; +import speakers from './speakers'; +import community from './community'; // Then we give our schema to the builder and provide the result to Sanity export default createSchema({ @@ -22,6 +26,10 @@ export default createSchema({ /* Your types here! */ post, author, - socialLink + socialLink, + donationV1, + donationV2, + speakers, + community ]) }); diff --git a/studio/schemas/speakers.js b/studio/schemas/speakers.js new file mode 100644 index 0000000..2242ab1 --- /dev/null +++ b/studio/schemas/speakers.js @@ -0,0 +1,32 @@ +export default { + name: 'speakers', + title: 'Speakers', + type: 'document', + fields: [ + { + name: 'title', + title: 'Title', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'description', + title: 'Description', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'titleLink', + title: 'Title Link', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'link', + title: 'Url', + type: 'url', + validation: Rule => Rule.required() + } + ] + }; + \ No newline at end of file diff --git a/types/index.ts b/types/index.ts index 92999ee..0f1e3a8 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,3 +1,5 @@ +import { SanityImageObject } from "@sanity/image-url/lib/types/types"; + export type SocialNetworkingItemT = { _id: string; social_item_link: Array<{ @@ -9,4 +11,26 @@ export type SocialNetworkingItemT = { social_name: string; }; +type Link = { + titleLink: string; + link: string; +} + +type Base = { + title: string; + description: string; +} + +export type SpeakersT = Base & Link; + +export type DonationV1T = Base & Link; + +export interface DonationV2T extends Base, Link { + picture: SanityImageObject; +} + +export interface CommunityT extends Base { + picture: SanityImageObject; +} + export type SocialNetworkingListT = Array; From 0e6d490f83d371fcb9b8e474eac1c91e145dfc7c Mon Sep 17 00:00:00 2001 From: Aleksandr Kudriavets <07aleks26@gmail.com> Date: Wed, 26 Oct 2022 23:12:49 +0300 Subject: [PATCH 4/7] Fix lint & prettier --- components/Community/community.tsx | 8 ++- components/Community/styles.module.scss | 8 +-- components/DonationV1/donation-v1.tsx | 2 +- components/DonationV1/styles.module.scss | 4 +- components/DonationV2/donation-v2.tsx | 2 +- components/DonationV2/styles.module.scss | 8 +-- components/Speakers/speakers.tsx | 2 +- components/Speakers/styles.module.scss | 4 +- lib/queries/community.js | 3 +- lib/queries/index.js | 14 ++--- pages/index.tsx | 50 +++++++++++----- studio/schemas/community.js | 51 ++++++++-------- studio/schemas/donation-v1.js | 61 ++++++++++--------- studio/schemas/donation-v2.js | 75 ++++++++++++------------ studio/schemas/speakers.js | 61 ++++++++++--------- types/index.ts | 6 +- 16 files changed, 189 insertions(+), 170 deletions(-) diff --git a/components/Community/community.tsx b/components/Community/community.tsx index 1d0557c..ab29049 100644 --- a/components/Community/community.tsx +++ b/components/Community/community.tsx @@ -5,7 +5,7 @@ import styles from './styles.module.scss'; type Props = { community: CommunityT; -} +}; export default function Community({ community }: Props) { const imageUrl = community.picture?.asset?._ref @@ -14,7 +14,6 @@ export default function Community({ community }: Props) { return (
-
@@ -22,7 +21,10 @@ export default function Community({ community }: Props) {

{community.title}

-

+

diff --git a/components/Community/styles.module.scss b/components/Community/styles.module.scss index 39477d2..589f738 100644 --- a/components/Community/styles.module.scss +++ b/components/Community/styles.module.scss @@ -12,17 +12,17 @@ .title { @apply text-3xl font-bold; - color: #1A1A1A; + color: #1a1a1a; } .description { @apply mt-3 text-sm md:text-sm; - color: #1A1A1A; + color: #1a1a1a; } .link { @apply inline-flex justify-center text-sm font-semibold py-2.5 px-4 text-white mt-6; - background-color: #191B1D; + background-color: #191b1d; } .image { @@ -32,4 +32,4 @@ & > span > img { @apply object-cover; } -} \ No newline at end of file +} diff --git a/components/DonationV1/donation-v1.tsx b/components/DonationV1/donation-v1.tsx index c9ccf47..dfd7a36 100644 --- a/components/DonationV1/donation-v1.tsx +++ b/components/DonationV1/donation-v1.tsx @@ -4,7 +4,7 @@ import styles from './styles.module.scss'; type Props = { donation: DonationV1T; -} +}; export default function DonationV1({ donation }: Props) { return ( diff --git a/components/DonationV1/styles.module.scss b/components/DonationV1/styles.module.scss index 9ee3552..8f92e40 100644 --- a/components/DonationV1/styles.module.scss +++ b/components/DonationV1/styles.module.scss @@ -17,5 +17,5 @@ .link { @apply inline-flex justify-center text-sm font-semibold py-2.5 px-4 bg-white mt-6 ml-8; - color: #191B1D; -} \ No newline at end of file + color: #191b1d; +} diff --git a/components/DonationV2/donation-v2.tsx b/components/DonationV2/donation-v2.tsx index 1b8a020..30b9142 100644 --- a/components/DonationV2/donation-v2.tsx +++ b/components/DonationV2/donation-v2.tsx @@ -6,7 +6,7 @@ import styles from './styles.module.scss'; type Props = { donation: DonationV2T; -} +}; export default function DonationV2({ donation }: Props) { const imageUrl = donation.picture?.asset?._ref diff --git a/components/DonationV2/styles.module.scss b/components/DonationV2/styles.module.scss index 1fd0ca6..e3a3208 100644 --- a/components/DonationV2/styles.module.scss +++ b/components/DonationV2/styles.module.scss @@ -12,17 +12,17 @@ .title { @apply text-3xl font-bold; - color: #1A1A1A; + color: #1a1a1a; } .description { @apply mt-3 text-sm md:text-sm; - color: #1A1A1A; + color: #1a1a1a; } .link { @apply inline-flex justify-center text-sm font-semibold py-2.5 px-4 text-white mt-6; - background-color: #191B1D; + background-color: #191b1d; } .image { @@ -32,4 +32,4 @@ & > span > img { @apply object-cover; } -} \ No newline at end of file +} diff --git a/components/Speakers/speakers.tsx b/components/Speakers/speakers.tsx index 6195f62..3c5d153 100644 --- a/components/Speakers/speakers.tsx +++ b/components/Speakers/speakers.tsx @@ -4,7 +4,7 @@ import styles from './styles.module.scss'; type Props = { speaker: SpeakersT; -} +}; export default function Speakers({ speaker }: Props) { return ( diff --git a/components/Speakers/styles.module.scss b/components/Speakers/styles.module.scss index 9ee3552..8f92e40 100644 --- a/components/Speakers/styles.module.scss +++ b/components/Speakers/styles.module.scss @@ -17,5 +17,5 @@ .link { @apply inline-flex justify-center text-sm font-semibold py-2.5 px-4 bg-white mt-6 ml-8; - color: #191B1D; -} \ No newline at end of file + color: #191b1d; +} diff --git a/lib/queries/community.js b/lib/queries/community.js index bf6b944..d4f86db 100644 --- a/lib/queries/community.js +++ b/lib/queries/community.js @@ -9,5 +9,4 @@ picture export const communityQuery = groq`*[_type == "community"][]{${communityItem}}`; -export default communityQuery - +export default communityQuery; diff --git a/lib/queries/index.js b/lib/queries/index.js index 7febee5..9a96a00 100644 --- a/lib/queries/index.js +++ b/lib/queries/index.js @@ -5,11 +5,11 @@ import speakers from './speakers'; import socialNetworksList from './social-network'; const queries = { - community, - donationV1, - donationV2, - socialNetworksList, - speakers -} + community, + donationV1, + donationV2, + socialNetworksList, + speakers +}; -export default queries; \ No newline at end of file +export default queries; diff --git a/pages/index.tsx b/pages/index.tsx index 89f877f..882b2bb 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -6,7 +6,13 @@ import DonationV2 from '@/components/DonationV2'; import DonationV1 from '@/components/DonationV1'; import Speakers from '@/components/Speakers'; import Community from '@/components/Community'; -import { CommunityT, DonationV1T, DonationV2T, SocialNetworkingListT, SpeakersT } from '../types'; +import { + CommunityT, + DonationV1T, + DonationV2T, + SocialNetworkingListT, + SpeakersT +} from '../types'; export default function Index({ socialNetworksList: initialSocialNetworksList, @@ -16,18 +22,27 @@ export default function Index({ community: initialCommunity, preview }) { - const { data: allDonationV1 } = usePreviewSubscription(queries.donationV1, { - initialData: initialDonationV1, - enabled: preview - }); - const { data: allDonationV2 } = usePreviewSubscription(queries.donationV1, { - initialData: initialDonationV2, - enabled: preview - }); - const { data: allCommunity } = usePreviewSubscription(queries.donationV1, { - initialData: initialCommunity, - enabled: preview - }); + const { data: allDonationV1 } = usePreviewSubscription( + queries.donationV1, + { + initialData: initialDonationV1, + enabled: preview + } + ); + const { data: allDonationV2 } = usePreviewSubscription( + queries.donationV1, + { + initialData: initialDonationV2, + enabled: preview + } + ); + const { data: allCommunity } = usePreviewSubscription( + queries.donationV1, + { + initialData: initialCommunity, + enabled: preview + } + ); const { data: allSocialList } = usePreviewSubscription( queries.socialNetworksList, { @@ -72,7 +87,14 @@ export async function getStaticProps({ preview = false }) { ); return { - props: { socialNetworksList, donationV1, donationV2, speakers, community, preview }, + props: { + socialNetworksList, + donationV1, + donationV2, + speakers, + community, + preview + }, // If webhooks isn't setup then attempt to re-generate in 1 minute intervals revalidate: process.env.SANITY_REVALIDATE_SECRET ? undefined : 60 }; diff --git a/studio/schemas/community.js b/studio/schemas/community.js index fd54a6f..0c9900e 100644 --- a/studio/schemas/community.js +++ b/studio/schemas/community.js @@ -1,27 +1,26 @@ export default { - name: 'community', - title: 'Community', - type: 'document', - fields: [ - { - name: 'title', - title: 'Title', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'description', - title: 'Description', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'picture', - title: 'Picture', - type: 'image', - options: { hotspot: true }, - validation: Rule => Rule.required() - } - ] - }; - \ No newline at end of file + name: 'community', + title: 'Community', + type: 'document', + fields: [ + { + name: 'title', + title: 'Title', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'description', + title: 'Description', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'picture', + title: 'Picture', + type: 'image', + options: { hotspot: true }, + validation: Rule => Rule.required() + } + ] +}; diff --git a/studio/schemas/donation-v1.js b/studio/schemas/donation-v1.js index 6577560..f6930fe 100644 --- a/studio/schemas/donation-v1.js +++ b/studio/schemas/donation-v1.js @@ -1,32 +1,31 @@ export default { - name: 'donation-v1', - title: 'Donation-v1', - type: 'document', - fields: [ - { - name: 'title', - title: 'Title', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'description', - title: 'Description', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'titleLink', - title: 'Title Link', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'link', - title: 'Url', - type: 'url', - validation: Rule => Rule.required() - } - ] - }; - \ No newline at end of file + name: 'donation-v1', + title: 'Donation-v1', + type: 'document', + fields: [ + { + name: 'title', + title: 'Title', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'description', + title: 'Description', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'titleLink', + title: 'Title Link', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'link', + title: 'Url', + type: 'url', + validation: Rule => Rule.required() + } + ] +}; diff --git a/studio/schemas/donation-v2.js b/studio/schemas/donation-v2.js index 274d749..a40eb6e 100644 --- a/studio/schemas/donation-v2.js +++ b/studio/schemas/donation-v2.js @@ -1,39 +1,38 @@ export default { - name: 'donation-v2', - title: 'Donation-v2', - type: 'document', - fields: [ - { - name: 'title', - title: 'Title', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'description', - title: 'Description', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'titleLink', - title: 'Title Link', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'link', - title: 'Url', - type: 'url', - validation: Rule => Rule.required() - }, - { - name: 'picture', - title: 'Picture', - type: 'image', - options: { hotspot: true }, - validation: Rule => Rule.required() - } - ] - }; - \ No newline at end of file + name: 'donation-v2', + title: 'Donation-v2', + type: 'document', + fields: [ + { + name: 'title', + title: 'Title', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'description', + title: 'Description', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'titleLink', + title: 'Title Link', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'link', + title: 'Url', + type: 'url', + validation: Rule => Rule.required() + }, + { + name: 'picture', + title: 'Picture', + type: 'image', + options: { hotspot: true }, + validation: Rule => Rule.required() + } + ] +}; diff --git a/studio/schemas/speakers.js b/studio/schemas/speakers.js index 2242ab1..f1791e7 100644 --- a/studio/schemas/speakers.js +++ b/studio/schemas/speakers.js @@ -1,32 +1,31 @@ export default { - name: 'speakers', - title: 'Speakers', - type: 'document', - fields: [ - { - name: 'title', - title: 'Title', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'description', - title: 'Description', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'titleLink', - title: 'Title Link', - type: 'string', - validation: Rule => Rule.required() - }, - { - name: 'link', - title: 'Url', - type: 'url', - validation: Rule => Rule.required() - } - ] - }; - \ No newline at end of file + name: 'speakers', + title: 'Speakers', + type: 'document', + fields: [ + { + name: 'title', + title: 'Title', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'description', + title: 'Description', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'titleLink', + title: 'Title Link', + type: 'string', + validation: Rule => Rule.required() + }, + { + name: 'link', + title: 'Url', + type: 'url', + validation: Rule => Rule.required() + } + ] +}; diff --git a/types/index.ts b/types/index.ts index 0f1e3a8..0f98091 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,4 +1,4 @@ -import { SanityImageObject } from "@sanity/image-url/lib/types/types"; +import { SanityImageObject } from '@sanity/image-url/lib/types/types'; export type SocialNetworkingItemT = { _id: string; @@ -14,12 +14,12 @@ export type SocialNetworkingItemT = { type Link = { titleLink: string; link: string; -} +}; type Base = { title: string; description: string; -} +}; export type SpeakersT = Base & Link; From 393dd6c9adebc15bd6938f26a9a2795bc6f0d141 Mon Sep 17 00:00:00 2001 From: Aleksandr Kudriavets <07aleks26@gmail.com> Date: Wed, 26 Oct 2022 23:18:24 +0300 Subject: [PATCH 5/7] Add alt --- components/Community/community.tsx | 2 +- components/DonationV2/donation-v2.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Community/community.tsx b/components/Community/community.tsx index ab29049..bf1c8fd 100644 --- a/components/Community/community.tsx +++ b/components/Community/community.tsx @@ -16,7 +16,7 @@ export default function Community({ community }: Props) {
- + community
diff --git a/components/DonationV2/donation-v2.tsx b/components/DonationV2/donation-v2.tsx index 30b9142..9b870fb 100644 --- a/components/DonationV2/donation-v2.tsx +++ b/components/DonationV2/donation-v2.tsx @@ -19,7 +19,7 @@ export default function DonationV2({ donation }: Props) {
- + donation
From 55f7c14983d6ec6f408d3bcd3237f53921b166c3 Mon Sep 17 00:00:00 2001 From: Aleksandr Kudriavets <07aleks26@gmail.com> Date: Thu, 27 Oct 2022 12:31:48 +0300 Subject: [PATCH 6/7] Fix build error --- components/Community/community.tsx | 9 +++++---- components/DonationV1/donation-v1.tsx | 9 +++++---- components/DonationV2/donation-v2.tsx | 13 +++++++------ components/Speakers/speakers.tsx | 9 +++++---- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/components/Community/community.tsx b/components/Community/community.tsx index bf1c8fd..8922b83 100644 --- a/components/Community/community.tsx +++ b/components/Community/community.tsx @@ -8,8 +8,9 @@ type Props = { }; export default function Community({ community }: Props) { - const imageUrl = community.picture?.asset?._ref - ? urlForImage(community.picture).url() + const { picture, title, description } = community || {}; + const imageUrl = picture?.asset?._ref + ? urlForImage(picture).url() : 'https://source.unsplash.com/630x441/'; return (
@@ -20,9 +21,9 @@ export default function Community({ community }: Props) {
-

{community.title}

+

{title}

diff --git a/components/DonationV1/donation-v1.tsx b/components/DonationV1/donation-v1.tsx index dfd7a36..d5bb43b 100644 --- a/components/DonationV1/donation-v1.tsx +++ b/components/DonationV1/donation-v1.tsx @@ -7,13 +7,14 @@ type Props = { }; export default function DonationV1({ donation }: Props) { + const { title, description, link, titleLink } = donation || {}; return (
-

{donation.title}

- {donation.description} - - {donation.titleLink} +

{title}

+ {description} + + {titleLink}
diff --git a/components/DonationV2/donation-v2.tsx b/components/DonationV2/donation-v2.tsx index 9b870fb..e04561e 100644 --- a/components/DonationV2/donation-v2.tsx +++ b/components/DonationV2/donation-v2.tsx @@ -9,13 +9,14 @@ type Props = { }; export default function DonationV2({ donation }: Props) { - const imageUrl = donation.picture?.asset?._ref - ? urlForImage(donation.picture).url() + const { picture, title, description, link, titleLink } = donation || {}; + const imageUrl = picture?.asset?._ref + ? urlForImage(picture).url() : 'https://source.unsplash.com/630x441/'; return (
-

{donation.title}

+

{title}

@@ -23,10 +24,10 @@ export default function DonationV2({ donation }: Props) {
-

{donation.description}

+

{description}

- - {donation.titleLink} + + {titleLink}
diff --git a/components/Speakers/speakers.tsx b/components/Speakers/speakers.tsx index 3c5d153..d8d7b95 100644 --- a/components/Speakers/speakers.tsx +++ b/components/Speakers/speakers.tsx @@ -7,13 +7,14 @@ type Props = { }; export default function Speakers({ speaker }: Props) { + const { title, description, link, titleLink } = speaker || {}; return (
-

{speaker.title}

- {speaker.description} - - {speaker.titleLink} +

{title}

+ {description} + + {titleLink}
From 60e502b441ff794c3742422d0f15248b33a96897 Mon Sep 17 00:00:00 2001 From: Aleksandr Kudriavets <07aleks26@gmail.com> Date: Thu, 27 Oct 2022 12:39:17 +0300 Subject: [PATCH 7/7] Fix build error --- components/DonationV1/donation-v1.tsx | 2 +- components/DonationV2/donation-v2.tsx | 2 +- components/Speakers/speakers.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/DonationV1/donation-v1.tsx b/components/DonationV1/donation-v1.tsx index d5bb43b..0d741ce 100644 --- a/components/DonationV1/donation-v1.tsx +++ b/components/DonationV1/donation-v1.tsx @@ -13,7 +13,7 @@ export default function DonationV1({ donation }: Props) {

{title}

{description} - + {titleLink}
diff --git a/components/DonationV2/donation-v2.tsx b/components/DonationV2/donation-v2.tsx index e04561e..f3f3f91 100644 --- a/components/DonationV2/donation-v2.tsx +++ b/components/DonationV2/donation-v2.tsx @@ -26,7 +26,7 @@ export default function DonationV2({ donation }: Props) {

{description}

- + {titleLink}
diff --git a/components/Speakers/speakers.tsx b/components/Speakers/speakers.tsx index d8d7b95..b51b639 100644 --- a/components/Speakers/speakers.tsx +++ b/components/Speakers/speakers.tsx @@ -13,7 +13,7 @@ export default function Speakers({ speaker }: Props) {

{title}

{description} - + {titleLink}