Skip to content

Commit

Permalink
Revert "Skeleton: add getSeoMeta (#2464)"
Browse files Browse the repository at this point in the history
This reverts commit de8ba2b.
  • Loading branch information
scottdixon committed Sep 12, 2024
1 parent 21f37eb commit 57dedc4
Show file tree
Hide file tree
Showing 38 changed files with 384 additions and 1,246 deletions.
5 changes: 0 additions & 5 deletions .changeset/grumpy-bees-notice.md

This file was deleted.

35 changes: 0 additions & 35 deletions examples/b2b/app/lib/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,38 +196,3 @@ export const FOOTER_QUERY = `#graphql
}
${MENU_FRAGMENT}
` as const;

export const PRODUCT_ITEM_FRAGMENT = `#graphql
fragment MoneyProductItem on MoneyV2 {
amount
currencyCode
}
fragment ProductItem on Product {
id
handle
title
featuredImage {
id
altText
url
width
height
}
priceRange {
minVariantPrice {
...MoneyProductItem
}
maxVariantPrice {
...MoneyProductItem
}
}
variants(first: 1) {
nodes {
selectedOptions {
name
value
}
}
}
}
` as const;
24 changes: 5 additions & 19 deletions examples/b2b/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {
useNonce,
getShopAnalytics,
Analytics,
getSeoMeta,
SeoConfig,
} from '@shopify/hydrogen';
import {defer, MetaArgs, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import {useNonce, getShopAnalytics, Analytics} from '@shopify/hydrogen';
import {defer, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import {
Links,
Meta,
Expand All @@ -22,7 +16,6 @@ import resetStyles from '~/styles/reset.css?url';
import appStyles from '~/styles/app.css?url';
import {PageLayout} from '~/components/PageLayout';
import {FOOTER_QUERY, HEADER_QUERY} from '~/lib/fragments';
import {seoPayload} from '~/lib/seo';
import {B2BLocationProvider} from '~/components/B2BLocationProvider';
import {B2BLocationSelector} from '~/components/B2BLocationSelector';
import type {
Expand Down Expand Up @@ -95,11 +88,7 @@ export type CustomerCompany =
/********** EXAMPLE UPDATE END ************/
/***********************************************/

export const meta = ({data}: MetaArgs<typeof loader>) => {
return getSeoMeta(data!.seo as SeoConfig);
};

export async function loader({context, request}: LoaderFunctionArgs) {
export async function loader({context}: LoaderFunctionArgs) {
const {storefront, customerAccount, cart, env} = context;
const publicStoreDomain = env.PUBLIC_STORE_DOMAIN;

Expand All @@ -115,19 +104,17 @@ export async function loader({context, request}: LoaderFunctionArgs) {
});

// await the header query (above the fold)
const header = await storefront.query(HEADER_QUERY, {
const headerPromise = storefront.query(HEADER_QUERY, {
cache: storefront.CacheLong(),
variables: {
headerMenuHandle: 'main-menu', // Adjust to your header menu handle
},
});

const seo = seoPayload.root({shop: header.shop, url: request.url});

return defer({
cart: cartPromise,
footer: footerPromise,
header,
header: await headerPromise,
isLoggedIn: isLoggedInPromise,
publicStoreDomain,
shop: getShopAnalytics({
Expand All @@ -142,7 +129,6 @@ export async function loader({context, request}: LoaderFunctionArgs) {
country: context.storefront.i18n.country,
language: context.storefront.i18n.language,
},
seo,
});
}

Expand Down
21 changes: 4 additions & 17 deletions examples/b2b/app/routes/products.$handle.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {Suspense} from 'react';
import {
defer,
MetaArgs,
redirect,
type LoaderFunctionArgs,
} from '@shopify/remix-oxygen';
import {defer, redirect, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import {
Await,
Link,
Expand All @@ -28,20 +23,18 @@ import {
Analytics,
type CartViewPayload,
useAnalytics,
getSeoMeta,
} from '@shopify/hydrogen';
import type {
CartLineInput,
SelectedOption,
} from '@shopify/hydrogen/storefront-api-types';
import {getVariantUrl} from '~/lib/variants';
import {seoPayload} from '~/lib/seo';
import {useAside} from '~/components/Aside';
import {QuantityRules, hasQuantityRules} from '~/components/QuantityRules';
import {PriceBreaks} from '~/components/PriceBreaks';

export const meta = ({matches}: MetaArgs<typeof loader>) => {
return getSeoMeta(...matches.map((match) => (match.data as any)?.seo));
export const meta: MetaFunction<typeof loader> = ({data}) => {
return [{title: `Hydrogen | ${data?.product.title ?? ''}`}];
};

export async function loader(args: LoaderFunctionArgs) {
Expand Down Expand Up @@ -126,12 +119,6 @@ async function loadCriticalData({
}
}

const seo = seoPayload.product({
product,
selectedVariant: product?.selectedVariant,
url: request.url,
});

// In order to show which variants are available in the UI, we need to query
// all of them. But there might be a *lot*, so instead separate the variants
// into it's own separate query that is deferred. So there's a brief moment
Expand All @@ -146,7 +133,7 @@ async function loadCriticalData({
/********** EXAMPLE UPDATE END *************/
/***********************************************/

return {product, variants, seo};
return {product, variants};
}

/**
Expand Down
64 changes: 29 additions & 35 deletions examples/b2b/storefrontapi.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,31 +245,6 @@ export type FooterQuery = {
>;
};

export type MoneyProductItemFragment = Pick<
StorefrontAPI.MoneyV2,
'amount' | 'currencyCode'
>;

export type ProductItemFragment = Pick<
StorefrontAPI.Product,
'id' | 'handle' | 'title'
> & {
featuredImage?: StorefrontAPI.Maybe<
Pick<StorefrontAPI.Image, 'id' | 'altText' | 'url' | 'width' | 'height'>
>;
priceRange: {
minVariantPrice: Pick<StorefrontAPI.MoneyV2, 'amount' | 'currencyCode'>;
maxVariantPrice: Pick<StorefrontAPI.MoneyV2, 'amount' | 'currencyCode'>;
};
variants: {
nodes: Array<{
selectedOptions: Array<
Pick<StorefrontAPI.SelectedOption, 'name' | 'value'>
>;
}>;
};
};

export type StoreRobotsQueryVariables = StorefrontAPI.Exact<{
country?: StorefrontAPI.InputMaybe<StorefrontAPI.CountryCode>;
language?: StorefrontAPI.InputMaybe<StorefrontAPI.LanguageCode>;
Expand Down Expand Up @@ -490,6 +465,31 @@ export type BlogsQuery = {
};
};

export type MoneyProductItemFragment = Pick<
StorefrontAPI.MoneyV2,
'amount' | 'currencyCode'
>;

export type ProductItemFragment = Pick<
StorefrontAPI.Product,
'id' | 'handle' | 'title'
> & {
featuredImage?: StorefrontAPI.Maybe<
Pick<StorefrontAPI.Image, 'id' | 'altText' | 'url' | 'width' | 'height'>
>;
priceRange: {
minVariantPrice: Pick<StorefrontAPI.MoneyV2, 'amount' | 'currencyCode'>;
maxVariantPrice: Pick<StorefrontAPI.MoneyV2, 'amount' | 'currencyCode'>;
};
variants: {
nodes: Array<{
selectedOptions: Array<
Pick<StorefrontAPI.SelectedOption, 'name' | 'value'>
>;
}>;
};
};

export type CollectionQueryVariables = StorefrontAPI.Exact<{
handle: StorefrontAPI.Scalars['String']['input'];
country?: StorefrontAPI.InputMaybe<StorefrontAPI.CountryCode>;
Expand All @@ -510,7 +510,6 @@ export type CollectionQuery = {
StorefrontAPI.Collection,
'id' | 'handle' | 'title' | 'description'
> & {
seo: Pick<StorefrontAPI.Seo, 'description' | 'title'>;
products: {
nodes: Array<
Pick<StorefrontAPI.Product, 'id' | 'handle' | 'title'> & {
Expand Down Expand Up @@ -550,9 +549,8 @@ export type CollectionQuery = {

export type CollectionFragment = Pick<
StorefrontAPI.Collection,
'id' | 'title' | 'handle' | 'description'
'id' | 'title' | 'handle'
> & {
seo: Pick<StorefrontAPI.Seo, 'description' | 'title'>;
image?: StorefrontAPI.Maybe<
Pick<StorefrontAPI.Image, 'id' | 'url' | 'altText' | 'width' | 'height'>
>;
Expand All @@ -574,11 +572,7 @@ export type StoreCollectionsQueryVariables = StorefrontAPI.Exact<{
export type StoreCollectionsQuery = {
collections: {
nodes: Array<
Pick<
StorefrontAPI.Collection,
'id' | 'title' | 'handle' | 'description'
> & {
seo: Pick<StorefrontAPI.Seo, 'description' | 'title'>;
Pick<StorefrontAPI.Collection, 'id' | 'title' | 'handle'> & {
image?: StorefrontAPI.Maybe<
Pick<
StorefrontAPI.Image,
Expand Down Expand Up @@ -1278,11 +1272,11 @@ interface GeneratedQueryTypes {
return: BlogsQuery;
variables: BlogsQueryVariables;
};
'#graphql\n #graphql\n fragment MoneyProductItem on MoneyV2 {\n amount\n currencyCode\n }\n fragment ProductItem on Product {\n id\n handle\n title\n featuredImage {\n id\n altText\n url\n width\n height\n }\n priceRange {\n minVariantPrice {\n ...MoneyProductItem\n }\n maxVariantPrice {\n ...MoneyProductItem\n }\n }\n variants(first: 1) {\n nodes {\n selectedOptions {\n name\n value\n }\n }\n }\n }\n\n query Collection(\n $handle: String!\n $country: CountryCode\n $language: LanguageCode\n $first: Int\n $last: Int\n $startCursor: String\n $endCursor: String\n ) @inContext(country: $country, language: $language) {\n collection(handle: $handle) {\n id\n handle\n title\n description\n seo {\n description\n title\n }\n products(\n first: $first,\n last: $last,\n before: $startCursor,\n after: $endCursor\n ) {\n nodes {\n ...ProductItem\n }\n pageInfo {\n hasPreviousPage\n hasNextPage\n endCursor\n startCursor\n }\n }\n }\n }\n': {
'#graphql\n #graphql\n fragment MoneyProductItem on MoneyV2 {\n amount\n currencyCode\n }\n fragment ProductItem on Product {\n id\n handle\n title\n featuredImage {\n id\n altText\n url\n width\n height\n }\n priceRange {\n minVariantPrice {\n ...MoneyProductItem\n }\n maxVariantPrice {\n ...MoneyProductItem\n }\n }\n variants(first: 1) {\n nodes {\n selectedOptions {\n name\n value\n }\n }\n }\n }\n\n query Collection(\n $handle: String!\n $country: CountryCode\n $language: LanguageCode\n $first: Int\n $last: Int\n $startCursor: String\n $endCursor: String\n ) @inContext(country: $country, language: $language) {\n collection(handle: $handle) {\n id\n handle\n title\n description\n products(\n first: $first,\n last: $last,\n before: $startCursor,\n after: $endCursor\n ) {\n nodes {\n ...ProductItem\n }\n pageInfo {\n hasPreviousPage\n hasNextPage\n endCursor\n startCursor\n }\n }\n }\n }\n': {
return: CollectionQuery;
variables: CollectionQueryVariables;
};
'#graphql\n fragment Collection on Collection {\n id\n title\n handle\n description\n seo {\n description\n title\n }\n image {\n id\n url\n altText\n width\n height\n }\n }\n query StoreCollections(\n $country: CountryCode\n $endCursor: String\n $first: Int\n $language: LanguageCode\n $last: Int\n $startCursor: String\n ) @inContext(country: $country, language: $language) {\n collections(\n first: $first,\n last: $last,\n before: $startCursor,\n after: $endCursor\n ) {\n nodes {\n ...Collection\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n': {
'#graphql\n fragment Collection on Collection {\n id\n title\n handle\n image {\n id\n url\n altText\n width\n height\n }\n }\n query StoreCollections(\n $country: CountryCode\n $endCursor: String\n $first: Int\n $language: LanguageCode\n $last: Int\n $startCursor: String\n ) @inContext(country: $country, language: $language) {\n collections(\n first: $first,\n last: $last,\n before: $startCursor,\n after: $endCursor\n ) {\n nodes {\n ...Collection\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n': {
return: StoreCollectionsQuery;
variables: StoreCollectionsQueryVariables;
};
Expand Down
24 changes: 3 additions & 21 deletions examples/classic-remix/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import {
useNonce,
getShopAnalytics,
Analytics,
getSeoMeta,
SeoConfig,
} from '@shopify/hydrogen';
import {
defer,
type MetaArgs,
type LoaderFunctionArgs,
} from '@shopify/remix-oxygen';
import {useNonce, getShopAnalytics, Analytics} from '@shopify/hydrogen';
import {defer, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import {
Links,
Meta,
Expand All @@ -35,7 +25,6 @@ import appStyles from '~/styles/app.css';
/***********************************************/
import {PageLayout} from '~/components/PageLayout';
import {FOOTER_QUERY, HEADER_QUERY} from '~/lib/fragments';
import {seoPayload} from '~/lib/seo';

export type RootLoader = typeof loader;

Expand Down Expand Up @@ -76,10 +65,6 @@ export function links() {
];
}

export const meta = ({data}: MetaArgs<typeof loader>) => {
return getSeoMeta(data!.seo as SeoConfig);
};

export async function loader(args: LoaderFunctionArgs) {
// Start fetching non-critical data without blocking time to first byte
const deferredData = loadDeferredData(args);
Expand Down Expand Up @@ -108,7 +93,7 @@ export async function loader(args: LoaderFunctionArgs) {
* Load data necessary for rendering content above the fold. This is the critical data
* needed to render the page. If it's unavailable, the whole page should 400 or 500 error.
*/
async function loadCriticalData({context, request}: LoaderFunctionArgs) {
async function loadCriticalData({context}: LoaderFunctionArgs) {
const {storefront} = context;

const [header] = await Promise.all([
Expand All @@ -121,11 +106,8 @@ async function loadCriticalData({context, request}: LoaderFunctionArgs) {
// Add other queries here, so that they are loaded in parallel
]);

const seo = seoPayload.root({shop: header.shop, url: request.url});

return {
header,
seo,
};
}

Expand Down
35 changes: 0 additions & 35 deletions examples/custom-cart-method/app/lib/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,41 +187,6 @@ export const FOOTER_QUERY = `#graphql
${MENU_FRAGMENT}
` as const;

export const PRODUCT_ITEM_FRAGMENT = `#graphql
fragment MoneyProductItem on MoneyV2 {
amount
currencyCode
}
fragment ProductItem on Product {
id
handle
title
featuredImage {
id
altText
url
width
height
}
priceRange {
minVariantPrice {
...MoneyProductItem
}
maxVariantPrice {
...MoneyProductItem
}
}
variants(first: 1) {
nodes {
selectedOptions {
name
value
}
}
}
}
` as const;

/***********************************************/
/********** EXAMPLE UPDATE STARTS ************/

Expand Down
Loading

0 comments on commit 57dedc4

Please sign in to comment.