Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
Disable generating paths during the buildtime
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofwolski committed May 5, 2022
1 parent a588bc7 commit 2567ea6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 39 deletions.
12 changes: 4 additions & 8 deletions pages/[channel]/[locale]/category/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Layout, PageHero, ProductCollection } from "@/components";
import { CategoryPageSeo } from "@/components/seo/CategoryPageSeo";
import apolloClient from "@/lib/graphql";
import { contextToRegionQuery } from "@/lib/regions";
import { categoryPaths } from "@/lib/ssr/category";
import {
CategoryBySlugDocument,
CategoryBySlugQuery,
Expand Down Expand Up @@ -56,13 +55,10 @@ function CategoryPage({ category }: InferGetStaticPropsType<typeof getStaticProp

export default CategoryPage;

export const getStaticPaths: GetStaticPaths = async () => {
const paths = await categoryPaths();
return {
paths,
fallback: "blocking",
};
};
export const getStaticPaths: GetStaticPaths = () => ({
paths: [],
fallback: "blocking",
});

CategoryPage.getLayout = function getLayout(page: ReactElement) {
return <Layout>{page}</Layout>;
Expand Down
12 changes: 4 additions & 8 deletions pages/[channel]/[locale]/collection/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Layout, PageHero, ProductCollection } from "@/components";
import { CollectionPageSeo } from "@/components/seo/CollectionPageSeo";
import apolloClient from "@/lib/graphql";
import { contextToRegionQuery } from "@/lib/regions";
import { collectionPaths } from "@/lib/ssr/collection";
import {
CollectionBySlugDocument,
CollectionBySlugQuery,
Expand Down Expand Up @@ -55,13 +54,10 @@ function CollectionPage({ collection }: InferGetStaticPropsType<typeof getStatic

export default CollectionPage;

export const getStaticPaths: GetStaticPaths = async () => {
const paths = await collectionPaths();
return {
paths,
fallback: "blocking",
};
};
export const getStaticPaths: GetStaticPaths = () => ({
paths: [],
fallback: "blocking",
});

CollectionPage.getLayout = function getLayout(page: ReactElement) {
return <Layout>{page}</Layout>;
Expand Down
12 changes: 4 additions & 8 deletions pages/[channel]/[locale]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { BaseSeo } from "@/components/seo/BaseSeo";
import { HOMEPAGE_MENU } from "@/lib/const";
import apolloClient from "@/lib/graphql";
import { contextToRegionQuery } from "@/lib/regions";
import { homepagePaths } from "@/lib/ssr/homepage";
import {
HomepageBlocksQuery,
HomepageBlocksQueryDocument,
Expand Down Expand Up @@ -54,13 +53,10 @@ function Home({ menuData }: InferGetStaticPropsType<typeof getStaticProps>) {

export default Home;

export const getStaticPaths: GetStaticPaths = async () => {
const paths = homepagePaths();
return {
paths,
fallback: "blocking",
};
};
export const getStaticPaths: GetStaticPaths = () => ({
paths: [],
fallback: "blocking",
});

Home.getLayout = function getLayout(page: ReactElement) {
return <Layout>{page}</Layout>;
Expand Down
12 changes: 4 additions & 8 deletions pages/[channel]/[locale]/page/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ReactElement } from "react";
import { Layout, RichText } from "@/components";
import apolloClient from "@/lib/graphql";
import { contextToRegionQuery } from "@/lib/regions";
import { pagePaths } from "@/lib/ssr/page";
import { translate } from "@/lib/translations";
import { PageDocument, PageQuery, PageQueryVariables } from "@/saleor/api";

Expand All @@ -16,13 +15,10 @@ export interface pathParams {
slug: string;
}

export const getStaticPaths: GetStaticPaths = async () => {
const paths = await pagePaths();
return {
paths,
fallback: "blocking",
};
};
export const getStaticPaths: GetStaticPaths = () => ({
paths: [],
fallback: "blocking",
});

export const getStaticProps = async (context: GetStaticPropsContext) => {
const pageSlug = context.params?.slug?.toString()!;
Expand Down
13 changes: 6 additions & 7 deletions pages/[channel]/[locale]/products/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ import {
export type OptionalQuery = {
variant?: string;
};
export const getStaticPaths: GetStaticPaths = async () =>
// Temporally do not render all possible products during the build time
// const paths = await productPaths();
({
paths: [],
fallback: "blocking",
});

export const getStaticPaths: GetStaticPaths = async () => ({
paths: [],
fallback: "blocking",
});

export const getStaticProps = async (context: GetStaticPropsContext) => {
const productSlug = context.params?.slug?.toString()!;
const response: ApolloQueryResult<ProductBySlugQuery> = await apolloClient.query<
Expand Down

0 comments on commit 2567ea6

Please sign in to comment.