Skip to content

Commit

Permalink
fix: index.json (#2080)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Jan 24, 2025
1 parent ce3644b commit e043c41
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/fern-docs/ui/src/hooks/useInterceptNextDataHref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ function createPageLoaderGetDataHref(
const buildId = window.__NEXT_DATA__.buildId;
const { pathname: hrefPathname, query, search } = parseRelativeUrl(href);
const { pathname: asPathname } = parseRelativeUrl(asPath);
const route = removeTrailingSlash(hrefPathname);
let route = removeTrailingSlash(hrefPathname);

if (route === "") {
route = "/index";
}

if (!route.startsWith("/")) {
throw new Error(`Route name should start with a "/", got "${route}"`);
}
Expand All @@ -30,6 +35,7 @@ function createPageLoaderGetDataHref(
removeTrailingSlash(addLocale(path, locale)),
".json"
);
// ->> /_next/data/development/index.json
return addPathPrefix(
`/_next/data/${buildId}${dataRoute}${search}`,
basePath
Expand Down

0 comments on commit e043c41

Please sign in to comment.