Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix redirect loop if no tags
Browse files Browse the repository at this point in the history
mosch committed Jan 28, 2025

Verified

This commit was signed with the committer’s verified signature.
marekful Marcell Fülöp
1 parent 381e809 commit b369526
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/zudoku/src/lib/plugins/openapi/index.tsx
Original file line number Diff line number Diff line change
@@ -60,6 +60,8 @@ const MethodColorMap: Record<string, keyof typeof ColorMap> = {

export type OpenApiPluginOptions = OasPluginConfig & InternalOasPluginConfig;

const UNTAGGED_PATH = "~endpoints";

export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
const basePath = joinUrl(config.navigationId ?? "/reference");
const versions = config.type === "file" ? Object.keys(config.input) : [];
@@ -175,7 +177,7 @@ export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
const categoryLink = joinUrl(
basePath,
urlVersion,
tag.name ? slugify(tag.name) : "~endpoints",
tag.name ? slugify(tag.name) : UNTAGGED_PATH,
);
return {
type: "category",
@@ -226,12 +228,13 @@ export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
children: [
{
index: true,
loader: () => {
return redirect(joinUrl(versionPath, tagPages.at(0)?.path));
},
loader: () =>
redirect(
joinUrl(versionPath, tagPages.at(0)?.path ?? UNTAGGED_PATH),
),
},
{
path: joinUrl(versionPath, "~endpoints"),
path: joinUrl(versionPath, UNTAGGED_PATH),
async lazy() {
const { OperationList } = await import("./OperationList.js");
return { element: <OperationList untagged={true} /> };

0 comments on commit b369526

Please sign in to comment.