Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/fern-docs/bundle/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const nextConfig: NextConfig = {
outputFileTracingRoot: isStandalone ? path.join(__dirname, "../../..") : undefined,

// speed up build
typescript: { ignoreBuildErrors: true },
typescript: { ignoreBuildErrors: process.env.VERCEL_ENV === "production" },
eslint: { ignoreDuringBuilds: true },

skipMiddlewareUrlNormalize: true,
Expand Down
20 changes: 20 additions & 0 deletions packages/fern-docs/bundle/src/app/AsyncStylesheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client";

interface AsyncStylesheetProps {
href: string;
crossOrigin?: "anonymous" | "use-credentials";
}

export function AsyncStylesheet({ href, crossOrigin }: AsyncStylesheetProps) {
return (
<link
rel="stylesheet"
href={href}
media="print"
crossOrigin={crossOrigin}
onLoad={(e) => {
(e.target as HTMLLinkElement).media = "all";
}}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
return redirectWithLoginError(req, redirectLocation, "unknown_error", "Couldn't login, please try again");
}

const oauthClient = new OryOAuth2Client(config);
const oauthClient = new OryOAuth2Client(config as Extract<typeof config, { partner: "ory" }>);
try {
const { access_token, refresh_token } = await oauthClient.getToken(code);
const token = OryAccessTokenSchema.parse(await oauthClient.decode(access_token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { getFaiClient } from "@/getFaiClient";
export const maxDuration = 60;
export const revalidate = 0;

export async function POST(req: NextRequest) {
export async function POST(req: NextRequest): Promise<NextResponse> {
if (isLocal() || isSelfHosted()) {
return NextResponse.json("Ask Fern is not available in local preview mode or self-hosted mode", {
status: 400
Expand Down Expand Up @@ -123,7 +123,7 @@ export async function POST(req: NextRequest) {
const queryIndexName = getQueryIndexName();
let result: Response | TurbopufferAuthError;

if (modelProvider === "anthropic" || modelProvider === "bedrock") {
if (modelProvider === "bedrock") {
result = await runRouteForAnthropic({
domain,
chatSource,
Expand Down Expand Up @@ -162,10 +162,10 @@ export async function POST(req: NextRequest) {

// Unauthorized error
if (result && typeof result === "object" && "error" in result && result.error === "unauthorized") {
return createAuthErrorStreamResponse(result.message);
return createAuthErrorStreamResponse(result.message) as NextResponse;
}

return result;
return result as NextResponse;
}

function createAuthErrorStreamResponse(errorMessage: string): Response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default async function EndpointSelectorPage({
scopedNode = node;
return false;
}
return true;
});
}

Expand All @@ -57,6 +58,7 @@ export default async function EndpointSelectorPage({
scopedNode = node;
return false;
}
return true;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default async function EndpointSelectorPage({
scopedNode = node;
return false;
}
return true;
});
}

Expand All @@ -57,6 +58,7 @@ export default async function EndpointSelectorPage({
scopedNode = node;
return false;
}
return true;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default async function Layout({
{/** HACKHACK: this is a hack to set the logo text to "Docs" for Cohere, this needs to be moved into docs.yml */}
<SetLogoText text={domain.includes("cohere") ? "Docs" : undefined} />
{config.defaultLanguage != null && <DefaultLanguage language={config.defaultLanguage} />}
<DarkCode value={edgeFlags.isDarkCodeEnabled || settings.darkModeCode} />
<DarkCode value={(edgeFlags.isDarkCodeEnabled || settings.darkModeCode) ?? false} />
<Whitelabeled value={edgeFlags.isWhitelabeled} />
<SetColors colors={colors} />
<SetIsAskAiEnabled isAskAiEnabled={isAskAiEnabled} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default async function EndpointSelectorPage({
scopedNode = node;
return false;
}
return true;
});
}

Expand All @@ -58,6 +59,7 @@ export default async function EndpointSelectorPage({
scopedNode = node;
return false;
}
return true;
});
}

Expand Down
7 changes: 3 additions & 4 deletions packages/fern-docs/bundle/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ConsoleMessage } from "@/components/console-message";
import { WebSocketRefresh } from "@/components/websocket-refresh";

import "./globals.css";
import { AsyncStylesheet } from "@/app/AsyncStylesheet";

const secrets = [
"ALGOLIA_API_KEY",
Expand Down Expand Up @@ -62,11 +63,9 @@ export default function Layout({ children }: { children: React.ReactNode }) {
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
crossOrigin="anonymous"
/>
<link
rel="stylesheet"
<AsyncStylesheet
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
media="print"
onload="this.media='all'"
crossOrigin="anonymous"
/>
<noscript
dangerouslySetInnerHTML={{
Expand Down
20 changes: 11 additions & 9 deletions packages/fern-docs/bundle/src/components/FernLinkCard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { cn } from "@fern-docs/components/cn";
import type { FernCardProps } from "@fern-docs/components/FernCard";
import { FernLink } from "@fern-docs/components/FernLink";
import type { LinkProps } from "next/link";
import { forwardRef, type PropsWithChildren } from "react";

export const FernLinkCard = forwardRef<HTMLAnchorElement, PropsWithChildren<FernCardProps & LinkProps>>(
function FernLinkCard({ children, className, ...props }, ref) {
return (
<FernLink className={cn("fern-card interactive", className)} {...props} ref={ref}>
{children}
</FernLink>
);
}
);
export const FernLinkCard = forwardRef<
HTMLAnchorElement,
PropsWithChildren<FernCardProps & Omit<LinkProps, "href"> & { href: string }>
>(function FernLinkCard({ children, className, ...props }, ref) {
return (
<FernLink className={cn("fern-card interactive", className)} {...props} ref={ref}>
{children}
</FernLink>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export interface RouteSuggestion {
subtitle?: string;
}

/**
* Safely extract title from a navigation node parent
*/
function getNodeTitle(node: FernNavigation.NavigationNodeParent): string | undefined {
if ("title" in node) {
return node.title;
}
return undefined;
}

/**
* Generate a breadcrumb-style subtitle from parent navigation nodes
*/
Expand All @@ -37,7 +47,7 @@ function generateSubtitle(
// Build breadcrumb from parents, excluding root
const breadcrumbParts = entry.parents
.filter((parent) => parent.type !== "root" && parent.type !== "sidebarRoot")
.map((parent) => parent.title)
.map(getNodeTitle)
.filter((title): title is string => title != null && title.length > 0);

return breadcrumbParts.length > 0 ? breadcrumbParts.join(" › ") : undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const WebhookResponseSection: React.FC = () => {
fallback={STATUS_200_TEXT}
size="sm"
className="mt-3 text-start"
useNextMdx={false}
engine="plaintext"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export async function WebSocketContent({
}
reference={
<TypeDefinitionRoot types={types} slug={node.slug}>
<TypeDefinitionSlotsServer types={types} serialize={serialize}>
<TypeDefinitionSlotsServer types={types}>
<CardedSection
number={1}
title={
Expand Down Expand Up @@ -173,7 +173,6 @@ export async function WebSocketContent({
<WithSeparator>
{headers.map((parameter) => (
<ObjectProperty
serialize={serialize}
key={parameter.key}
property={parameter}
types={types}
Expand All @@ -189,7 +188,6 @@ export async function WebSocketContent({
<WithSeparator>
{channel.pathParameters.map((parameter) => (
<ObjectProperty
serialize={serialize}
key={parameter.key}
property={parameter}
types={types}
Expand All @@ -206,7 +204,6 @@ export async function WebSocketContent({
{channel.queryParameters.map((parameter) => {
return (
<ObjectProperty
serialize={serialize}
key={parameter.key}
property={parameter}
types={types}
Expand All @@ -232,11 +229,7 @@ export async function WebSocketContent({
</span>
}
>
<TypeReferenceDefinitions
serialize={serialize}
shape={publishMessageShape}
types={types}
/>
<TypeReferenceDefinitions shape={publishMessageShape} types={types} />
</EndpointSection>
</TypeDefinitionAnchorPart>
)}
Expand All @@ -252,11 +245,7 @@ export async function WebSocketContent({
</span>
}
>
<TypeReferenceDefinitions
serialize={serialize}
shape={subscribeMessageShape}
types={types}
/>
<TypeReferenceDefinitions shape={subscribeMessageShape} types={types} />
</EndpointSection>
</TypeDefinitionAnchorPart>
)}
Expand All @@ -266,7 +255,7 @@ export async function WebSocketContent({
footer={<FooterLayout bottomNavigation={bottomNavigation} hideFeedback={hideFeedback} />}
>
<PlaygroundKeyboardTrigger />
<MdxServerComponentProseSuspense serialize={serialize} mdx={channel.description} />
<MdxServerComponentProseSuspense mdx={channel.description} />
</ReferenceLayout>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export async function ChangelogPageOverview({
: undefined
}
/>
<Markdown mdx={mdx} fallback={page?.markdown} useNextMdx={mdx?.engine === "next-remote"} />
<Markdown mdx={mdx} fallback={page?.markdown} engine={mdx?.engine} />
</>
);
}
Expand Down Expand Up @@ -166,12 +166,12 @@ export async function ChangelogPageEntry({
return (
<Markdown
mdx={mdx}
useNextMdx={mdx?.engine === "next-remote"}
engine={mdx?.engine}
title={
title != null ? (
<h2>
<FernLink href={slugToHref(node.slug)} className="not-prose" scroll={true}>
<MdxContent mdx={title} useNextMdx={mdx?.engine === "next-remote"} />
<MdxContent mdx={title} engine={mdx?.engine} />
</FernLink>
</h2>
) : undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,13 @@ export async function LayoutEvaluator({
pageHeader={pageHeader}
aside={
mdx && exports?.Aside ? (
<MdxAside
code={mdx.code}
jsxElements={mdx.jsxElements}
useNextMdx={mdx?.engine === "next-remote"}
/>
<MdxAside code={mdx.code} jsxElements={mdx.jsxElements} engine={mdx?.engine} />
) : undefined
}
footer={footer}
builtWithFern={<BuiltWithFern className="mx-auto my-8 w-fit" />}
>
<MdxContent mdx={mdx} fallback={markdown} useNextMdx={mdx?.engine === "next-remote"} />
<MdxContent mdx={mdx} fallback={markdown} engine={mdx?.engine} />
</AbstractLayoutEvaluatorContent>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const WithLabelInternal: FC<PropsWithChildren<WithLabelInternalProps>> =
{description != null && (
<FernTooltip
// todo: server-side render this
content={<Markdown mdx={description} size="xs" useNextMdx={false} fallback={description} />}
content={<Markdown mdx={description} size="xs" engine="plaintext" fallback={description} />}
delayDuration={0}
>
<HelpCircle className="text-(color:--grayscale-a11) size-4 self-center" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export function PlaygroundAuthorizationFormCard({
}: PlaygroundAuthorizationFormCardProps): ReactElement<any> | null {
return (
<PlaygroundAuthorizationFormCardRoot>
<PlaygroundAuthorizationCardTrigger auth={auth} disabled={disabled} />
<PlaygroundAuthorizationCardTrigger
auth={auth}
disabled={disabled}
loader={loader}
apiDefinitionId={apiDefinitionId}
/>
<PlaygroundAuthorizationFormCardContent>
<div className="fern-dropdown max-h-full">
<PlaygroundAuthorizationForm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import type { DocsLoader } from "@fern-api/docs-server/docs-loader";
import type { APIV1Read } from "@fern-api/fdr-sdk";
import { Button } from "@fern-docs/components/button";
import { FernCollapse } from "@fern-docs/components/FernCollapse";
Expand Down Expand Up @@ -72,16 +73,27 @@ export function usePlaygroundAuthorizationFormCard() {
return React.useContext(PlaygroundAuthorizationFormCardCtx);
}

export function PlaygroundAuthorizationCardTrigger({ auth, disabled }: { auth: APIV1Read.ApiAuth; disabled: boolean }) {
const { open, toggleOpen, setOpen } = usePlaygroundAuthorizationFormCard();
export function PlaygroundAuthorizationCardTrigger({
auth,
disabled,
loader,
apiDefinitionId
}: {
auth: APIV1Read.ApiAuth;
disabled: boolean;
loader: DocsLoader;
apiDefinitionId: string;
}) {
const { open, toggleOpen } = usePlaygroundAuthorizationFormCard();
const apiKeyInjection = useApiKeyInjectionConfig();
return apiKeyInjection.enabled ? (
<PlaygroundCardTriggerApiKeyInjected
auth={auth}
config={apiKeyInjection}
disabled={disabled}
toggleOpen={toggleOpen}
onClose={() => setOpen(false)}
loader={loader}
apiDefinitionId={apiDefinitionId}
/>
) : (
<PlaygroundCardTriggerManual auth={auth} disabled={disabled} isOpen={open} toggleOpen={toggleOpen} />
Expand Down
Loading