Skip to content

Commit

Permalink
Feat/sanity setup (#106)
Browse files Browse the repository at this point in the history
* chore: setup with pnpm

* feat: working with sanity

* chore: remove consoles

* chore: matched types for faq card

* chore: testing out .vercelignore

* chore: testing out .vercelignore

* 1.5.0
  • Loading branch information
kunalkeshan authored Apr 7, 2023
1 parent e5abe51 commit d7dc407
Show file tree
Hide file tree
Showing 22 changed files with 10,198 additions and 2,696 deletions.
2 changes: 2 additions & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
santiy
studio
4 changes: 4 additions & 0 deletions @types/data.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface Faq {
question: string;
answer: string;
}
10 changes: 10 additions & 0 deletions client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// client.ts
import { createClient } from "@sanity/client";

const client = createClient({
projectId: "gj9kvgjn",
dataset: "production",
useCdn: false, // `false` if you want to ensure fresh data
});

export default client;
5 changes: 1 addition & 4 deletions components/contact/FaqCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
*/

import React, { useState } from "react";
import FAQ from "../../data/faqs";
import { FaPlus } from "react-icons/fa";
import { motion, AnimatePresence } from "framer-motion";

type FaqDataType = typeof FAQ[number];

const FaqCard: React.FC<FaqDataType> = ({ question, answer }) => {
const FaqCard: React.FC<Faq> = ({ question, answer }) => {
const [isOpen, setIsOpen] = useState(false);

const OpenAnimation = {
Expand Down
11 changes: 8 additions & 3 deletions components/contact/FrequentlyAskedQuestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
*/

import React from "react";
import FAQ from "../../data/faqs";
import FaqCard from "./FaqCard";

const FrequentlyAskedQuestions = () => {
interface FrequentlyAskedQuestionsProps {
faqs: Faq[];
}

const FrequentlyAskedQuestions: React.FC<FrequentlyAskedQuestionsProps> = ({
faqs,
}) => {
return (
<div className="mt-20 scroll-mt-20" id="faqs">
<h2 className="text-center text-5xl font-semibold">
Expand All @@ -18,7 +23,7 @@ const FrequentlyAskedQuestions = () => {
answer any of your questions.
</p>
<div className="mt-8 flex flex-col gap-8">
{FAQ.map((faq, index) => (
{faqs.map((faq, index) => (
<FaqCard key={index} {...faq} />
))}
</div>
Expand Down
46 changes: 0 additions & 46 deletions data/faqs.ts

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kunalkeshan-dev",
"version": "1.4.1",
"version": "1.5.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -11,6 +11,7 @@
},
"dependencies": {
"@next/font": "^13.2.3",
"@sanity/client": "^5.4.2",
"@types/node": "18.11.10",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.9",
Expand Down
17 changes: 15 additions & 2 deletions pages/contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import PublicLayout from "../layouts/PublicLayout";
import { motion } from "framer-motion";
import Contact from "../components/contact/Contact";
import FrequentlyAskedQuestions from "../components/contact/FrequentlyAskedQuestions";
import client from "../client";
import { InferGetStaticPropsType, NextPage, GetStaticProps } from "next";

const ContactPage = () => {
const ContactPage: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = ({
faqs,
}) => {
return (
<>
<Head>
Expand All @@ -24,11 +28,20 @@ const ContactPage = () => {
className="mx-auto mt-10 mb-20 max-w-7xl px-5"
>
<Contact />
<FrequentlyAskedQuestions />
<FrequentlyAskedQuestions faqs={faqs} />
</motion.section>
</PublicLayout>
</>
);
};

export const getStaticProps: GetStaticProps<{ faqs: Faq[] }> = async () => {
const faqs = await client.fetch(`*[_type == "faqs"]`);
return {
props: {
faqs,
},
};
};

export default ContactPage;
Loading

1 comment on commit d7dc407

@vercel
Copy link

@vercel vercel bot commented on d7dc407 Apr 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.