diff --git a/README.md b/README.md index d6e8fddcf..1690bdd7a 100644 --- a/README.md +++ b/README.md @@ -144,13 +144,13 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following `sidebarOptions` can be configured with the following options: -| Name | Type | Default | Description | -| -------------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`. | -| `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category link pages when grouping paths by tag.

The supported options are as follows:

`tag`: Sets the category link config type to `generated-index` and uses the tag description as the link config description.

`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios).

`none`: Does not create pages for categories, only groups that can be expanded/collapsed. | -| `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. | -| `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. | -| `customProps` | `object` | `null` | Additional props for customizing a sidebar item. | +| Name | Type | Default | Description | +| -------------------- | --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`. | +| `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category pages when grouping paths by tag. By default, pages are not created for categories, only groups that can be expanded/collapsed.

The supported options are as follows:

`auto`: Sets the category link config type to `generated-index`, building an index page with links to each page in the group.

`tag`: Sets the category link config type to `generated-index` and uses the tag description at the top of the page.

`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios). | +| `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. | +| `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. | +| `customProps` | `object` | `null` | Additional props for customizing a sidebar item. | > You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.js` slice with the configured options will be generated within the respective `outputDir`. diff --git a/demo/docs/intro.mdx b/demo/docs/intro.mdx index 778eaa928..7bd15ba80 100644 --- a/demo/docs/intro.mdx +++ b/demo/docs/intro.mdx @@ -312,7 +312,7 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following | Name | Type | Default | Description | | -------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`. | -| `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category link pages when grouping paths by tag.

The supported options are as follows:

`tag`: Sets the category link config type to `generated-index` and uses the tag description as the link config description.

`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios).

`none`: Does not create pages for categories, only groups that can be expanded/collapsed. | +| `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category pages when grouping paths by tag. By default, pages are not created for categories, only groups that can be expanded/collapsed.

The supported options are as follows:

`auto`: Sets the category link config type to `generated-index`, building an index page with links to each page in the group.

`tag`: Sets the category link config type to `generated-index` and uses the tag description at the top of the page.

`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios). | | `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. | | `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. | | `customProps` | `object` | `null` | Additional props for customizing a sidebar item. | @@ -389,4 +389,4 @@ For more insight into why we decided to completely fork see [#47](https://github See [SUPPORT.md](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/SUPPORT.md) for our support agreement and guidelines. -If you believe you found a bug or have an idea you'd like to suggest you may [report an issue](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/new/choose) or [start a discussion](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/discussions/new/choose). \ No newline at end of file +If you believe you found a bug or have an idea you'd like to suggest you may [report an issue](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/new/choose) or [start a discussion](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/discussions/new/choose). diff --git a/packages/docusaurus-plugin-openapi-docs/README.md b/packages/docusaurus-plugin-openapi-docs/README.md index 1938d882e..f2b5035d1 100644 --- a/packages/docusaurus-plugin-openapi-docs/README.md +++ b/packages/docusaurus-plugin-openapi-docs/README.md @@ -133,13 +133,13 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following `sidebarOptions` can be configured with the following options: -| Name | Type | Default | Description | -| -------------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`. | -| `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category link pages when grouping paths by tag.

The supported options are as follows:

`tag`: Sets the category link config type to `generated-index` and uses the tag description as the link config description.

`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios).

`none`: Does not create pages for categories, only groups that can be expanded/collapsed. | -| `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. | -| `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. | -| `customProps` | `object` | `null` | Additional props for customizing a sidebar item. | +| Name | Type | Default | Description | +| -------------------- | --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`. | +| `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category pages when grouping paths by tag. By default, pages are not created for categories, only groups that can be expanded/collapsed.

The supported options are as follows:

`auto`: Sets the category link config type to `generated-index`, building an index page with links to each page in the group.

`tag`: Sets the category link config type to `generated-index` and uses the tag description at the top of the page.

`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios). | +| `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. | +| `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. | +| `customProps` | `object` | `null` | Additional props for customizing a sidebar item. | > You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.js` slice with the configured options will be generated within the respective `outputDir`. diff --git a/packages/docusaurus-plugin-openapi-docs/src/options.ts b/packages/docusaurus-plugin-openapi-docs/src/options.ts index d57b2b85a..91c154508 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/options.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/options.ts @@ -9,8 +9,7 @@ import { Joi } from "@docusaurus/utils-validation"; const sidebarOptions = Joi.object({ groupPathsBy: Joi.string().valid("tag"), - // TODO: Remove "none" in 2.0, make it the default if not specified - categoryLinkSource: Joi.string().valid("tag", "info", "none"), + categoryLinkSource: Joi.string().valid("tag", "info", "auto"), customProps: Joi.object(), sidebarCollapsible: Joi.boolean(), sidebarCollapsed: Joi.boolean(), diff --git a/packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts b/packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts index fd2538edb..285415ead 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts @@ -130,6 +130,7 @@ function groupByTags( ); // TODO: perhaps move this into a getLinkConfig() function + // Default to no link config (spindowns only) let linkConfig = undefined; if (taggedInfoObject !== undefined && categoryLinkSource === "info") { linkConfig = { @@ -151,8 +152,7 @@ function groupByTags( } as SidebarItemCategoryLinkConfig; } - // Default behavior - if (categoryLinkSource === undefined) { + if (categoryLinkSource === "auto") { linkConfig = { type: "generated-index" as "generated-index", title: tag, diff --git a/packages/docusaurus-plugin-openapi-docs/src/types.ts b/packages/docusaurus-plugin-openapi-docs/src/types.ts index d4da22eec..df4a3f262 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/types.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/types.ts @@ -46,7 +46,7 @@ export interface APIOptions { export interface SidebarOptions { groupPathsBy?: string; - categoryLinkSource?: string; + categoryLinkSource?: "info" | "tag" | "auto"; customProps?: { [key: string]: unknown }; sidebarCollapsible?: boolean; sidebarCollapsed?: boolean;