Skip to content

Commit

Permalink
fix canonicals
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgimenes committed Jun 13, 2022
1 parent 1402d4d commit fce6305
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
2 changes: 2 additions & 0 deletions @generated/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2767,6 +2767,7 @@ export type CollectionPageQueryQuery = {
titleTemplate: string | null
title: string | null
description: string | null
siteUrl: string | null
} | null
} | null
}
Expand Down Expand Up @@ -2847,6 +2848,7 @@ export type HomePageQueryQuery = {
title: string | null
description: string | null
titleTemplate: string | null
siteUrl: string | null
} | null
} | null
}
Expand Down
4 changes: 2 additions & 2 deletions @generated/graphql/persisted.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"ProductGalleryQuery": "query ProductGalleryQuery($first: Int!, $after: String!, $sort: StoreSort!, $term: String!, $selectedFacets: [IStoreSelectedFacet!]!) {\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n edges {\n node {\n id: productID\n slug\n sku\n brand {\n brandName: name\n name\n }\n name\n gtin\n isVariantOf {\n productGroupID\n name\n }\n image {\n url\n alternateName\n }\n offers {\n lowPrice\n offers {\n availability\n price\n listPrice\n quantity\n seller {\n identifier\n }\n }\n }\n }\n }\n }\n facets {\n key\n label\n type\n values {\n label\n value\n selected\n quantity\n }\n }\n }\n}\n",
"CollectionPageQuery": "query CollectionPageQuery {\n site {\n siteMetadata {\n titleTemplate\n title\n description\n }\n }\n}\n",
"CollectionPageQuery": "query CollectionPageQuery {\n site {\n siteMetadata {\n titleTemplate\n title\n description\n siteUrl\n }\n }\n}\n",
"ServerCollectionPageQuery": "query ServerCollectionPageQuery($slug: String!) {\n collection(slug: $slug) {\n seo {\n title\n description\n }\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n meta {\n selectedFacets {\n key\n value\n }\n }\n }\n}\n",
"ProductPageQuery": "query ProductPageQuery {\n site {\n siteMetadata {\n title\n description\n titleTemplate\n siteUrl\n }\n }\n}\n",
"ServerProductPageQuery": "query ServerProductPageQuery($slug: String!) {\n product(locator: [{key: \"slug\", value: $slug}]) {\n id: productID\n seo {\n title\n description\n canonical\n }\n brand {\n name\n }\n sku\n gtin\n name\n description\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n image {\n url\n alternateName\n }\n offers {\n lowPrice\n highPrice\n priceCurrency\n offers {\n availability\n price\n priceValidUntil\n priceCurrency\n itemCondition\n seller {\n identifier\n }\n listPrice\n }\n }\n isVariantOf {\n productGroupID\n name\n }\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n}\n",
"HomePageQuery": "query HomePageQuery {\n site {\n siteMetadata {\n title\n description\n titleTemplate\n }\n }\n}\n",
"HomePageQuery": "query HomePageQuery {\n site {\n siteMetadata {\n title\n description\n titleTemplate\n siteUrl\n }\n }\n}\n",
"SearchPageQuery": "query SearchPageQuery {\n site {\n siteMetadata {\n titleTemplate\n title\n description\n }\n }\n}\n",
"ValidateCartMutation": "mutation ValidateCartMutation($cart: IStoreCart!) {\n validateCart(cart: $cart) {\n order {\n orderNumber\n acceptedOffer {\n seller {\n identifier\n }\n quantity\n price\n listPrice\n itemOffered {\n sku\n name\n image {\n url\n alternateName\n }\n brand {\n name\n }\n isVariantOf {\n productGroupID\n name\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n }\n }\n messages {\n text\n status\n }\n }\n}\n",
"BrowserProductQuery": "query BrowserProductQuery($locator: [IStoreSelectedFacet!]!) {\n product(locator: $locator) {\n id: productID\n sku\n name\n gtin\n description\n isVariantOf {\n productGroupID\n name\n }\n image {\n url\n alternateName\n }\n brand {\n name\n }\n offers {\n lowPrice\n offers {\n availability\n price\n listPrice\n seller {\n identifier\n }\n }\n }\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n}\n",
Expand Down
7 changes: 2 additions & 5 deletions src/pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function Page(props: Props) {
const {
data: { site },
serverData,
location: { host },
slug,
} = props

Expand All @@ -73,10 +72,7 @@ function Page(props: Props) {
const { page } = searchParams
const title = collection?.seo.title ?? site?.siteMetadata?.title ?? ''
const pageQuery = page !== 0 ? `?page=${page}` : ''
const canonical =
host !== undefined
? `https://${host}/${slug}/${pageQuery}`
: `/${slug}/${pageQuery}`
const canonical = `${site?.siteMetadata?.siteUrl}/${slug}${pageQuery}`

return (
<SearchProvider
Expand Down Expand Up @@ -147,6 +143,7 @@ export const querySSG = graphql`
titleTemplate
title
description
siteUrl
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/pages/[slug]/p.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import type {
} from '@generated/graphql'
import { ITEMS_PER_SECTION } from 'src/constants'

import storeConfig from '../../../store.config'

import 'src/styles/pages/pdp.scss'

export type Props = PageProps<
Expand Down Expand Up @@ -47,7 +45,7 @@ function Page(props: Props) {

const title = seo.title || site?.siteMetadata?.title || ''
const description = seo.description || site?.siteMetadata?.description || ''
const canonical = `https://${storeConfig.storeUrl}${seo.canonical}`
const canonical = `${site?.siteMetadata?.siteUrl}${seo.canonical}`

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ export type Props = PageProps<HomePageQueryQuery>
function Page(props: Props) {
const {
data: { site },
location: { pathname, host },
} = props

const { locale } = useSession()

const title = site?.siteMetadata?.title ?? ''
const siteUrl = `https://${host}${pathname}`
const siteUrl = `${site?.siteMetadata?.siteUrl}`

return (
<>
Expand Down Expand Up @@ -121,6 +120,7 @@ export const querySSG = graphql`
title
description
titleTemplate
siteUrl
}
}
}
Expand Down

0 comments on commit fce6305

Please sign in to comment.