Skip to content

Commit

Permalink
confirm that changelog still works
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Jun 3, 2024
1 parent c099a39 commit 464b1db
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 54 deletions.
4 changes: 2 additions & 2 deletions packages/ui/app/src/sidebar/SidebarLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const SidebarLinkInternal = forwardRef<HTMLButtonElement, SidebarLinkProps>((pro
data-state={showIndicator ? "active" : "inactive"}
>
<ChevronDown
className={cn("size-5 lg:size-icon lg:my-0.5", {
className={cn("size-5 lg:size-icon", {
"-rotate-90": !expanded,
"rotate-0": expanded,
})}
Expand Down Expand Up @@ -167,7 +167,7 @@ const SidebarLinkInternal = forwardRef<HTMLButtonElement, SidebarLinkProps>((pro
))}
<span className="fern-sidebar-link-content">
{icon != null && (
<span className="mr-3 inline-flex items-center text-faded group-data-[state=active]:text-text-default">
<span className="mr-3 inline-flex items-center text-faded group-data-[state=active]:t-accent-aaa my-0.5">
{typeof icon === "string" ? (
<RemoteFontAwesomeIcon
icon={icon}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/sidebar/nodes/SidebarApiGroupNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FernNavigation } from "@fern-api/fdr-sdk";
import { SidebarApiSectionChild } from "./SidebarApiSectionChild";

interface SidebarApiGroupNodeProps {
nodeChildren: FernNavigation.ApiSectionChild[];
nodeChildren: (FernNavigation.ApiSectionChild | FernNavigation.ChangelogNode)[];
}
export function SidebarApiGroupNode({ nodeChildren }: SidebarApiGroupNodeProps): React.ReactElement {
return (
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/app/src/sidebar/nodes/SidebarApiSectionChild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { FernNavigation } from "@fern-api/fdr-sdk";
import { visitDiscriminatedUnion } from "@fern-ui/core-utils";
import { SidebarApiLeafNode } from "./SidebarApiLeafNode";
import { SidebarApiSectionNode } from "./SidebarApiSectionNode";
import { SidebarChangelogNode } from "./SidebarChangelogNode";
import { SidebarEndpointPairNode } from "./SidebarEndpointPairNode";
import { SidebarLinkNode } from "./SidebarLinkNode";
import { SidebarPageNode } from "./SidebarPageNode";

interface SidebarApiSectionChild {
node: FernNavigation.ApiSectionChild;
node: FernNavigation.ApiSectionChild | FernNavigation.ChangelogNode;
depth: number;
}

Expand All @@ -20,5 +21,6 @@ export function SidebarApiSectionChild({ node, depth }: SidebarApiSectionChild):
webSocket: (node) => <SidebarApiLeafNode node={node} depth={depth} />,
webhook: (node) => <SidebarApiLeafNode node={node} depth={depth} />,
apiSection: (node) => <SidebarApiSectionNode node={node} depth={depth} />,
changelog: (node) => <SidebarChangelogNode node={node} depth={depth} />,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export function SidebarRootApiSectionNode({
<SidebarApiSectionChild node={child} depth={1} />
</li>
))}
{node.type === "apiReference" && node.changelog != null && (
<li>
<SidebarApiSectionChild node={node.changelog} depth={1} />
</li>
)}
</ul>
</>
);
Expand Down
24 changes: 13 additions & 11 deletions packages/ui/app/src/sidebar/nodes/SidebarRootNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface SidebarRootNodeProps {
}

type ApiGroupOrSection =
| { type: "apiGroup"; children: FernNavigation.ApiSectionChild[] }
| { type: "apiGroup"; children: (FernNavigation.ApiSectionChild | FernNavigation.ChangelogNode)[] }
| FernNavigation.ApiSectionNode;

export function SidebarRootNode({ node }: SidebarRootNodeProps): React.ReactElement {
Expand All @@ -36,18 +36,20 @@ export function SidebarRootNode({ node }: SidebarRootNodeProps): React.ReactElem

const groups: ApiGroupOrSection[] = [];

apiRef.children.forEach((child) => {
if (child.type === "apiSection") {
groups.push(child);
} else {
const lastGroup = last(groups);
if (lastGroup?.type === "apiGroup") {
lastGroup.children.push(child);
[...apiRef.children, ...(apiRef.changelog != null ? [apiRef.changelog] : [])].forEach(
(child) => {
if (child.type === "apiSection") {
groups.push(child);
} else {
groups.push({ type: "apiGroup", children: [child] });
const lastGroup = last(groups);
if (lastGroup?.type === "apiGroup") {
lastGroup.children.push(child);
} else {
groups.push({ type: "apiGroup", children: [child] });
}
}
}
});
},
);

return (
<Fragment key={child.id}>
Expand Down
54 changes: 27 additions & 27 deletions packages/ui/app/src/util/convertNavigatableToResolvedPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,7 @@ export async function convertNavigatableToResolvedPath({
const neighbors = await getNeighbors(found, pages);
const { node, apiReference } = found;

if (apiReference != null) {
const api = apis[apiReference.apiDefinitionId];
if (api == null) {
return;
}
const holder = FernNavigation.ApiDefinitionHolder.create(api);
const typeResolver = new ApiTypeResolver(api.types);
// const [prunedApiDefinition] = findAndPruneApiSection(fullSlug, flattenedApiDefinition);
const apiDefinition = await ApiDefinitionResolver.resolve(
apiReference,
holder,
typeResolver,
pages,
mdxOptions,
featureFlags,
domain,
);
return {
type: "api-page",
fullSlug: found.node.slug,
api: apiReference.apiDefinitionId,
apiDefinition,
// artifacts: apiSection.artifacts ?? null, // TODO: add artifacts
showErrors: apiReference.showErrors ?? false,
neighbors,
};
} else if (node.type === "changelog") {
if (node.type === "changelog") {
const pageContent = node.overviewPageId != null ? pages[node.overviewPageId] : undefined;
const serializedMdxContent =
pageContent != null ? await serializeMdxWithFrontmatter(pageContent.markdown, mdxOptions) : null;
Expand Down Expand Up @@ -137,6 +111,32 @@ export async function convertNavigatableToResolvedPath({
items: await Promise.all(itemsPromise),
neighbors,
};
} else if (apiReference != null) {
const api = apis[apiReference.apiDefinitionId];
if (api == null) {
return;
}
const holder = FernNavigation.ApiDefinitionHolder.create(api);
const typeResolver = new ApiTypeResolver(api.types);
// const [prunedApiDefinition] = findAndPruneApiSection(fullSlug, flattenedApiDefinition);
const apiDefinition = await ApiDefinitionResolver.resolve(
apiReference,
holder,
typeResolver,
pages,
mdxOptions,
featureFlags,
domain,
);
return {
type: "api-page",
fullSlug: found.node.slug,
api: apiReference.apiDefinitionId,
apiDefinition,
// artifacts: apiSection.artifacts ?? null, // TODO: add artifacts
showErrors: apiReference.showErrors ?? false,
neighbors,
};
} else if (node.type === "page") {
const pageContent = pages[node.pageId];
if (pageContent == null) {
Expand Down
14 changes: 8 additions & 6 deletions packages/ui/docs-bundle/src/utils/getDocsPageProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,14 @@ async function convertDocsToDocsPageProps({
}),
),
currentVersionIndex: node.currentVersion == null ? undefined : node.versions.indexOf(node.currentVersion),
versions: node.versions.map((version, index) => ({
id: version.versionId,
slug: version.slug,
index,
availability: version.availability,
})),
versions: node.versions
.filter((version) => !version.hidden)
.map((version, index) => ({
id: version.versionId,
slug: version.slug,
index,
availability: version.availability,
})),
sidebar: node.sidebar,
},
featureFlags,
Expand Down
14 changes: 8 additions & 6 deletions packages/ui/local-preview-bundle/src/utils/getDocsPageProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ export async function getDocsPageProps(
}),
),
currentVersionIndex: node.currentVersion == null ? undefined : node.versions.indexOf(node.currentVersion),
versions: node.versions.map((version, index) => ({
id: version.versionId,
slug: version.slug,
index,
availability: version.availability,
})),
versions: node.versions
.filter((version) => !version.hidden)
.map((version, index) => ({
id: version.versionId,
slug: version.slug,
index,
availability: version.availability,
})),
sidebar: node.sidebar,
},
featureFlags,
Expand Down

0 comments on commit 464b1db

Please sign in to comment.