Adds sitemap. (#982)

This commit is contained in:
Michael Novotny
2023-04-23 13:55:25 -05:00
committed by GitHub
parent ee900a48e8
commit a53ee3e3a0
6 changed files with 82 additions and 15 deletions

View File

@@ -13,7 +13,7 @@ import {
getCollectionsQuery
} from './queries/collection';
import { getMenuQuery } from './queries/menu';
import { getPageQuery } from './queries/page';
import { getPageQuery, getPagesQuery } from './queries/page';
import {
getProductQuery,
getProductRecommendationsQuery,
@@ -36,6 +36,7 @@ import {
ShopifyCreateCartOperation,
ShopifyMenuOperation,
ShopifyPageOperation,
ShopifyPagesOperation,
ShopifyProduct,
ShopifyProductOperation,
ShopifyProductRecommendationsOperation,
@@ -279,7 +280,8 @@ export async function getCollections(): Promise<Collection[]> {
title: 'All',
description: 'All products'
},
path: '/search'
path: '/search',
updatedAt: new Date().toISOString()
},
// Filter out the `hidden` collections.
// Collections that start with `hidden-*` need to be hidden on the search page.
@@ -316,6 +318,14 @@ export async function getPage(handle: string): Promise<Page> {
return res.body.data.pageByHandle;
}
export async function getPages(): Promise<Page[]> {
const res = await shopifyFetch<ShopifyPagesOperation>({
query: getPagesQuery
});
return removeEdgesAndNodes(res.body.data.pages);
}
export async function getProduct(handle: string): Promise<Product | undefined> {
const res = await shopifyFetch<ShopifyProductOperation>({
query: getProductQuery,