Skip to content

Commit

Permalink
Use fallback rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelehen committed Feb 9, 2023
1 parent a8a17bc commit 1cec28c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/pages/internal/metrics/[metricId]/[regionSlug]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ import { metricCatalog } from "src/utils/metrics";
import { regions } from "src/utils/regions";
import { getRegionSlug } from "src/utils/routing";

const MetricPage: NextPage<{ regionId: string; metricId: string }> = ({
const MetricPage: NextPage<{ regionId?: string; metricId?: string }> = ({
regionId,
metricId,
}) => {
metricId = metricId ?? metricCatalog.metrics[0].id;
regionId = regionId ?? regions.all[0].regionId;

const metric = metricCatalog.getMetric(metricId);
const region = regions.findByRegionIdStrict(regionId);
const metricFullName = metric.extendedName
Expand Down Expand Up @@ -178,14 +181,18 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
};

export const getStaticPaths: GetStaticPaths = async () => {
const paths = regions.all
.map((region) =>
metricCatalog.metrics.map((metric) => ({
params: { regionSlug: getRegionSlug(region), metricId: metric.id },
}))
)
.flat();
return { paths, fallback: false };
// Prerendering pages for all metric+region combinations is slow and can cause
// failed builds. So we use fallback rendering.
return { paths: [], fallback: true };

// const paths = regions.all
// .map((region) =>
// metricCatalog.metrics.map((metric) => ({
// params: { regionSlug: getRegionSlug(region), metricId: metric.id },
// }))
// )
// .flat();
// return { paths, fallback: false };
};

export default MetricPage;

0 comments on commit 1cec28c

Please sign in to comment.