Skip to content

Commit

Permalink
Implement Availability custom markdown component (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
kafkas authored Sep 13, 2023
1 parent afdb9fb commit 80c9bd5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ui/app/src/mdx/MdxContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Tr,
Ul,
} from "./base-components";
import { Availability } from "./components/Availability";
import { Callout } from "./components/Callout";
import { Card } from "./components/Card";
import { Cards } from "./components/Cards";
Expand Down Expand Up @@ -56,6 +57,7 @@ const COMPONENTS: MDXRemoteProps["components"] = {
li: Li,
a: A,
strong: Strong,
Availability,
Cards,
Card,
CodeBlock,
Expand Down
26 changes: 26 additions & 0 deletions packages/ui/app/src/mdx/components/Availability.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type * as FernRegistryApiRead from "@fern-fern/registry-browser/api/resources/api/resources/v1/resources/read";
import { EndpointAvailabilityTag } from "../../api-page/endpoints/EndpointAvailabilityTag";

export declare namespace Availability {
export interface Props {
type: string;
}
}

function parseAvailability(type: unknown): FernRegistryApiRead.Availability {
if (typeof type !== "string") {
return "GenerallyAvailable";
} else if (type === "GenerallyAvailable" || type.toLowerCase() === "ga") {
return "GenerallyAvailable";
} else if (type.toLowerCase() === "beta") {
return "Beta";
} else if (type.toLowerCase() === "deprecated") {
return "Deprecated";
} else {
return "GenerallyAvailable";
}
}

export const Availability: React.FC<Availability.Props> = ({ type }) => {
return <EndpointAvailabilityTag availability={parseAvailability(type)} />;
};

1 comment on commit 80c9bd5

@vercel
Copy link

@vercel vercel bot commented on 80c9bd5 Sep 13, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

fern-dev – ./packages/ui/fe-bundle

devtest.buildwithfern.com
fern-dev-git-main-buildwithfern.vercel.app
app-dev.buildwithfern.com
fern-dev-buildwithfern.vercel.app

Please sign in to comment.