Skip to content

Commit

Permalink
Add hydrogen sitemap routes
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpprieto committed Oct 31, 2024
1 parent 35965f4 commit ef9120b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 363 deletions.
333 changes: 0 additions & 333 deletions app/lib/sitemap.ts

This file was deleted.

18 changes: 0 additions & 18 deletions app/routes/[sitemap-empty.xml].tsx

This file was deleted.

10 changes: 2 additions & 8 deletions app/routes/[sitemap.xml].tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import type {LoaderFunctionArgs} from '@shopify/remix-oxygen';

Check failure on line 1 in app/routes/[sitemap.xml].tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

There should be no empty line within import group

import {getSitemapIndex} from 'app/lib/sitemap';
import {getSitemapIndex} from '@shopify/hydrogen';

export async function loader({
request,
context: {storefront},
}: LoaderFunctionArgs) {
const url = new URL(request.url);
const baseUrl = url.origin;

const response = await getSitemapIndex({
storefront,
request,
types: ['products', 'pages', 'collections', 'articles'],
customUrls: [`${baseUrl}/sitemap-empty.xml`],
});

response.headers.set('Oxygen-Cache-Control', `max-age=${60 * 60 * 24}`);
response.headers.set('Vary', 'Accept-Encoding, Accept-Language');
response.headers.set('Cache-Control', `max-age=${60 * 60 * 24}`);

return response;
}
Loading

0 comments on commit ef9120b

Please sign in to comment.