Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/components/postCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ function urlFor(_ref) {
}
export default props => {
console.log("Post Card: ", props.node)
const link = urlFor(props.node.logo.asset._ref).url()
const link = urlFor(props.node.images[0].asset._ref).url()
console.log("Card Link: ", link)
return (
<article
className={`post-card ${props.count % 3 === 0 && `post-card-large`} ${
props.postClass
}
${urlFor(props.node.logo.asset._ref) ? `with-image` : `no-image`}`}
${urlFor(props.node.images[0].asset._ref) ? `with-image` : `no-image`}`}
style={
props.node.logo.asset._ref && {
backgroundImage: `url(${urlFor(props.node.logo.asset._ref).url()})`,
props.node.images[0].asset._ref && {
backgroundImage: `url(${urlFor(
props.node.images[0].asset._ref
).url()})`,
}
}
>
Expand Down
35 changes: 30 additions & 5 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,31 @@ import imageUrlBuilder from "@sanity/image-url"
const BlogIndex = ({ data }, location) => {
const siteTitle = data.site.siteMetadata.title
const posts = data.allMarkdownRemark.edges
const [logos, setLogos] = useState([])
// const [logos, setLogos] = useState([])
const [images, setImages] = useState([])
let postCounter = 0
useEffect(() => {
onLoad()
}, [])
// async function onLoad() {
// try {
// const products = await client.fetch(`
// *[_type == 'vendor']`)
// console.log("testing 123", products)
// setLogos(products)
// } catch (e) {
// if (e !== "No current user") {
// alert(e)
// }
// }
// // setIsLoading(false);
// }
async function onLoad() {
try {
const products = await client.fetch(`
*[_type == 'vendor']`)
*[_type == 'product']`)
console.log("testing 123", products)
setLogos(products)
setImages(products)
} catch (e) {
if (e !== "No current user") {
alert(e)
Expand All @@ -47,7 +61,7 @@ const BlogIndex = ({ data }, location) => {
</header>
)} */}
<div className="post-feed">
{logos.map((logo, i) => {
{/* {logos.map((logo, i) => {
postCounter++
return (
<PostCard
Expand All @@ -56,7 +70,18 @@ const BlogIndex = ({ data }, location) => {
node={logo}
postClass={`post`}
/>
// <h1>yo</h1>
)
})} */}
{images.map((image, i) => {
console.log("Image:", image)
postCounter++
return (
<PostCard
key={image.slug.current}
count={postCounter}
node={image}
postClass={`post`}
/>
)
})}
{/* <div className="post-feed">
Expand Down