Skip to content

Commit 60d8f1a

Browse files
committed
Connected Sanity backend
1 parent 0a9b364 commit 60d8f1a

36 files changed

+12814
-257
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NEXT_PUBLIC_SANITY_TOKEN = skxjuOeFqGI0VuzMcThXkf1d7QTpygziADzD3J2eLUCtpsVfNsr4kBhmNtOQLqvsMSxDSSne1KQu3BaWiLCHzcntbdcU0pQoP5VrhrIEkfBN6cYt4ZnYG5EzkjOwr1yjkiLZm48AIu1sgCUUcXrL81sTYikwCk0yjAdIwPZKJRp4BjQmclUG

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
# dependencies
4-
/node_modules
4+
node_modules
55
/.pnp
66
.pnp.js
77

components/Cart.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const Cart = () => {
4+
return (
5+
<div>Cart</div>
6+
)
7+
}
8+
9+
export default Cart

components/Footer.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const Footer = () => {
4+
return (
5+
<div>Footer</div>
6+
)
7+
}
8+
9+
export default Footer

components/FooterBanner.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const FooterBanner = () => {
4+
return (
5+
<div>FooterBanner</div>
6+
)
7+
}
8+
9+
export default FooterBanner

components/HeroBanner.jsx

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from "react";
2+
import Link from "next/link";
3+
4+
import { urlFor } from "../lib/client";
5+
6+
const HeroBanner = ({ heroBanner }) => {
7+
return (
8+
<div className="hero-banner-container">
9+
<div>
10+
<p className="beats-solo">{heroBanner.smallText}</p>
11+
<h3>{heroBanner.midText}</h3>
12+
<h1>{heroBanner.largeText1}</h1>
13+
<img
14+
src={urlFor(heroBanner.image)}
15+
alt="headphones"
16+
className="hero-banner-image"
17+
/>
18+
<div>
19+
<Link href={`/product/heroBanner.product`}>
20+
<button type="button">{heroBanner.buttonText}</button>
21+
</Link>
22+
<div className="desc">
23+
<h5>Description</h5>
24+
<p>{heroBanner.desc}</p>
25+
</div>
26+
</div>
27+
</div>
28+
</div>
29+
);
30+
};
31+
32+
export default HeroBanner;

components/Layout.jsx

Whitespace-only changes.

components/Navbar.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
3+
const Navbar = () => {
4+
return (
5+
<div>Navbar</div>
6+
)
7+
}
8+
9+
export default Navbar

components/Product.jsx

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from "react";
2+
import Link from "next/link";
3+
4+
import { urlFor } from "../lib/client";
5+
6+
const Product = ({ product: { image, name, slug, price } }) => {
7+
return (
8+
<div>
9+
<Link href={`/product/${slug.current}`}>
10+
<div className="product-card">
11+
<img
12+
src={urlFor(image && image[0])}
13+
width={250}
14+
height={250}
15+
className="product-image"
16+
/>
17+
<p className="product-name">{name}</p>
18+
<p className="product-price">${price}</p>
19+
</div>
20+
</Link>
21+
</div>
22+
);
23+
};
24+
25+
export default Product;

components/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export { default as Footer } from "./Footer";
2+
export { default as Cart } from "./Cart";
3+
export { default as FooterBanner } from "./FooterBanner";
4+
export { default as HeroBanner } from "./HeroBanner";
5+
export { default as Layout } from "./Layout";
6+
export { default as Navbar } from "./Navbar";
7+
export { default as Product } from "./Product";

lib/client.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import sanityClient from "@sanity/client";
2+
import imageUrlBuilder from "@sanity/image-url";
3+
4+
export const client = sanityClient({
5+
projectId: "rnf15voj",
6+
dataset: "production",
7+
apiVersion: "2022-03-10",
8+
useCdn: true,
9+
token: process.env.NEXT_PUBLIC_SANITY_TOKEN,
10+
});
11+
12+
const builder = imageUrlBuilder(client);
13+
14+
export const urlFor = (source) => builder.image(source);

0 commit comments

Comments
 (0)