Skip to content

Commit

Permalink
optional chaining operator
Browse files Browse the repository at this point in the history
Added optional chaining operator for all queries
  • Loading branch information
salymk committed Feb 9, 2021
1 parent 6dc5d9b commit f4daa24
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/components/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const About = () => {
}
`);

const { to, description, image } = data.wpPage.sections.about;
const { to, description, image } = data.wpPage.sections?.about;
return (
<section>
<div id={to} className="bg-white pt-8 lg:pt-24">
Expand Down
2 changes: 1 addition & 1 deletion src/components/call-to-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CallToAction = () => {
subheadline,
ctaButton,
image,
} = data.wpPage.sections.callToAction;
} = data.wpPage.sections?.callToAction;
return (
<div className="relative mb-20">
<div className="absolute inset-0 flex flex-col" aria-hidden="true">
Expand Down
7 changes: 6 additions & 1 deletion src/components/car-tint.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ const CarTint = () => {
}
`);

const { to, title, subtitle, features } = data.wpPage.sections.automotiveTint;
const {
to,
title,
subtitle,
features,
} = data.wpPage.sections?.automotiveTint;

return (
<div id={to} className="bg-white">
Expand Down
2 changes: 1 addition & 1 deletion src/components/carbon-price.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const CarbonPrice = () => {
fourDoors,
features,
ctaButton,
} = data.wpPage.sections.carbonPrice;
} = data.wpPage.sections?.carbonPrice;
return (
<div className="flex flex-col rounded-lg shadow-lg overflow-hidden">
<div className="px-6 py-8 bg-white sm:p-10 sm:pb-6">
Expand Down
2 changes: 1 addition & 1 deletion src/components/carbon-tint.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const CarbonTint = () => {
}
}
`);
const { title, subtitle, features, image } = data.wpPage.sections.carbonTint;
const { title, subtitle, features, image } = data.wpPage.sections?.carbonTint;

return (
<div className="relative mt-12 lg:mt-24 lg:grid lg:grid-cols-2 lg:gap-8 lg:items-center">
Expand Down
2 changes: 1 addition & 1 deletion src/components/carbon-vs-ceramic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const CarbonVSCeramic = () => {
}
`);

const { title, subtitle } = data.wpPage.sections.carbonVsCeramic;
const { title, subtitle } = data.wpPage.sections?.carbonVsCeramic;

return (
<div className="relative">
Expand Down
2 changes: 1 addition & 1 deletion src/components/ceramic-price .js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const CeramicPrice = () => {
fourDoors,
features,
ctaButton,
} = data.wpPage.sections.ceramicPrice;
} = data.wpPage.sections?.ceramicPrice;
return (
<div className="flex flex-col rounded-lg shadow-lg overflow-hidden">
<div className="px-6 py-8 bg-white sm:p-10 sm:pb-6">
Expand Down
7 changes: 6 additions & 1 deletion src/components/ceramic-tint.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ const CeramicTint = () => {
}
}
`);
const { title, subtitle, features, image } = data.wpPage.sections.ceramicTint;
const {
title,
subtitle,
features,
image,
} = data.wpPage.sections?.ceramicTint;

return (
<div className="relative mt-12 sm:mt-16 lg:mt-24">
Expand Down
2 changes: 1 addition & 1 deletion src/components/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Contact = () => {
address,
phone,
email,
} = data.wpPage.sections.contact;
} = data.wpPage.sections?.contact;

return (
<section>
Expand Down
2 changes: 1 addition & 1 deletion src/components/faq.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const FAQ = () => {
}
}
`);
const { to, title, questions } = data.wpPage.sections.faq;
const { to, title, questions } = data.wpPage.sections?.faq;
return (
<section id={to}>
<div className="bg-gray-50">
Expand Down
2 changes: 1 addition & 1 deletion src/components/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Footer = () => {
}
`);

const { items } = data.wpPage.sections.menuItems;
const { items } = data.wpPage.sections?.menuItems;
const {
facebookLink,
instagramLink,
Expand Down
2 changes: 1 addition & 1 deletion src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const Header = () => {
}
`);

const { items, phoneCta } = data?.wpPage?.sections?.menuItems;
const { items, phoneCta } = data.wpPage.sections?.menuItems;
return (
<>
{/* This example requires Tailwind CSS v2.0+ */}
Expand Down
2 changes: 1 addition & 1 deletion src/components/hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Hero = () => {
bookBtn,
learnBtn,
image,
} = data.wpPage.sections.hero;
} = data.wpPage.sections?.hero;

return (
<section>
Expand Down
2 changes: 1 addition & 1 deletion src/components/pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Pricing = () => {
}
`);

const { to, title, heading, subheading } = data.wpPage.sections.pricing;
const { to, title, heading, subheading } = data.wpPage.sections?.pricing;

return (
<section id={to}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/reviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Reviews = () => {
}
`);

const { to, sectionTitle, customerReviews } = data.wpPage.sections.reviews;
const { to, sectionTitle, customerReviews } = data.wpPage.sections?.reviews;

return (
<section>
Expand Down
2 changes: 1 addition & 1 deletion src/components/seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function SEO({ description, lang, meta, keywords, title }) {
}
`);

const metaDescription = description || site.siteMetadata.description;
const metaDescription = description || site.siteMetadata?.description;

return (
<Helmet
Expand Down
2 changes: 1 addition & 1 deletion src/components/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Services = () => {
}
`);

const { headlightTinting, vinylWrap } = data.wpPage.sections.moreServices;
const { headlightTinting, vinylWrap } = data.wpPage.sections?.moreServices;
return (
<>
<section className="mx-auto mb-12">
Expand Down

0 comments on commit f4daa24

Please sign in to comment.