Skip to content

Commit

Permalink
docs: fix vercel build (#7876)
Browse files Browse the repository at this point in the history
* revert #7873
* [...page] doesn't generate unversioned or external paths
  • Loading branch information
yuhan committed May 13, 2022
1 parent 993a3aa commit a4d79e3
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
24 changes: 24 additions & 0 deletions docs/content/_navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -712,5 +712,29 @@
"path": "/community/public-apis"
}
]
},
{
"title": "Changelog",
"icon": "Change",
"path": "/changelog",
"isUnversioned": true,
"children": [
{
"title": "Changelog",
"path": "/changelog",
"isUnversioned": true
},
{
"title": "Migration Guides",
"path": "/migration",
"isUnversioned": true
}
]
},
{
"title": "Dagster Cloud Docs",
"icon": "Cloud",
"path": "https://docs.dagster.cloud/",
"isExternalLink": true
}
]
26 changes: 25 additions & 1 deletion docs/next/.versioned_content/_versioned_navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -29586,6 +29586,30 @@
"icon": "Users",
"path": "/community",
"title": "Community"
},
{
"children": [
{
"isUnversioned": true,
"path": "/changelog",
"title": "Changelog"
},
{
"isUnversioned": true,
"path": "/migration",
"title": "Migration Guides"
}
],
"icon": "Change",
"isUnversioned": true,
"path": "/changelog",
"title": "Changelog"
},
{
"icon": "Cloud",
"isExternalLink": true,
"path": "https://docs.dagster.cloud/",
"title": "Dagster Cloud Docs"
}
],
"0.14.2": [
Expand Down Expand Up @@ -35254,4 +35278,4 @@
"title": "Community"
}
]
}
}
4 changes: 2 additions & 2 deletions docs/next/pages/[...page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { versionFromPage } from "../util/useVersion";
import axios from "axios";
import { GetStaticProps } from "next";
import { MdxRemote } from "next-mdx-remote/types";
import { latestAllPaths } from "util/useNavigation";
import { latestAllVersionedPaths } from "util/useNavigation";
import { promises as fs } from "fs";
import generateToc from "mdast-util-toc";
import matter from "gray-matter";
Expand Down Expand Up @@ -251,7 +251,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {

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

type NavEntry = {
title: string;
path: string;
children?: NavEntry[];
icon?: string;
isUnversioned?: boolean;
isExternalLink?: boolean;
};
export function flatten(yx: any) {
const xs = JSON.parse(JSON.stringify(yx));

Expand Down Expand Up @@ -39,6 +47,20 @@ export const latestAllPaths = () => {
});
};

export const latestAllVersionedPaths = () => {
// latest version, excluding paths that are
return flatten(versionedNavigation[latestVersion])
.filter((n: NavEntry) => n.path && !n.isExternalLink && !n.isUnversioned)
.map(({ path }) => path.split("/").splice(1))
.map((page: string[]) => {
return {
params: {
page: page,
},
};
});
};

export const allPaths = () => {
let paths = [];

Expand Down

1 comment on commit a4d79e3

@vercel
Copy link

@vercel vercel bot commented on a4d79e3 May 13, 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.