Skip to content

Commit

Permalink
[docs infra] speed up vercel build with ISR (#6773)
Browse files Browse the repository at this point in the history
* [docs infra] speed up vercel build with ISR
* 60 -> 600
  • Loading branch information
yuhan committed Feb 25, 2022
1 parent 6327300 commit 1f5a7ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/next/pages/[...page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Link from "../components/Link";
import { MdxRemote } from "next-mdx-remote/types";
import { NextSeo } from "next-seo";
import SidebarNavigation, { getItems } from "components/mdx/SidebarNavigation";
import { allPaths } from "util/useNavigation";
import { latestAllPaths } from "util/useNavigation";
import { promises as fs } from "fs";
import generateToc from "mdast-util-toc";
import hydrate from "next-mdx-remote/hydrate";
Expand Down Expand Up @@ -393,7 +393,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
githubLink,
},
},
revalidate: 10, // In seconds
revalidate: 600, // In seconds; This enables Incremental Static Regeneration
};
} catch (err) {
console.error(err);
Expand All @@ -405,7 +405,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {

export function getStaticPaths({}) {
return {
paths: allPaths(),
paths: latestAllPaths(), // only generate pages of latest version at build time
fallback: true,
};
}
6 changes: 3 additions & 3 deletions docs/next/util/useNavigation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import masterNavigation from "../../content/_navigation.json";
import { useVersion } from "./useVersion";
import { useVersion, latestVersion } from "./useVersion";
import versionedNavigation from "../.versioned_content/_versioned_navigation.json";

export function flatten(yx: any) {
Expand All @@ -26,8 +26,8 @@ export const useNavigation = () => {
};

export const latestAllPaths = () => {
// Master
return flatten(masterNavigation)
// latest version
return flatten(versionedNavigation[latestVersion])
.filter((n: { path: any }) => n.path)
.map(({ path }) => path.split("/").splice(1))
.map((page: string[]) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/next/util/useVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const defaultVersion =
process.env.NODE_ENV === "production"
? ALL_VERSIONS[ALL_VERSIONS.length - 1]
: "master";
const latestVersion = ALL_VERSIONS[ALL_VERSIONS.length - 1];
export const latestVersion = ALL_VERSIONS[ALL_VERSIONS.length - 1];

export function normalizeVersionPath(
asPath: string,
Expand Down

1 comment on commit 1f5a7ec

@vercel
Copy link

@vercel vercel bot commented on 1f5a7ec Feb 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.