Skip to content

Commit

Permalink
docs: improve sidebar items custom props docs (#8888)
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Apr 13, 2023
1 parent 35183d7 commit 1458689
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion website/docs/api/plugins/plugin-content-docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Accepted fields:
| `sidebar_label` | `string` | `title` | The text shown in the document sidebar for this document. |
| `sidebar_position` | `number` | Default ordering | Controls the position of a doc inside the generated sidebar slice when using `autogenerated` sidebar items. See also [Autogenerated sidebar metadata](/docs/sidebar#autogenerated-sidebar-metadata). |
| `sidebar_class_name` | `string` | `undefined` | Gives the corresponding sidebar label a special class name when using autogenerated sidebars. |
| `sidebar_custom_props` | `string` | `undefined` | Assign custom metadata to the sidebar item referencing this doc. |
| `sidebar_custom_props` | `object` | `undefined` | Assign [custom props](../../guides/docs/sidebar/index.mdx#passing-custom-props) to the sidebar item referencing this doc |
| `displayed_sidebar` | `string` | `undefined` | Force the display of a given sidebar when browsing the current document. Read the [multiple sidebars guide](../../guides/docs/sidebar/multiple-sidebars.mdx) for details. |
| `hide_title` | `boolean` | `false` | Whether to hide the title at the top of the doc. It only hides a title declared through the front matter, and have no effect on a Markdown title at the top of your document. |
| `hide_table_of_contents` | `boolean` | `false` | Whether to hide the table of contents to the right. |
Expand Down
7 changes: 5 additions & 2 deletions website/docs/guides/docs/sidebar/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,18 @@ module.exports = {

## Passing custom props {#passing-custom-props}

To pass in custom props to a swizzled sidebar item, add the optional `customProps` object to any of the items:
To pass in custom props to a sidebar item, add the optional `customProps` object to any of the items. This is useful to apply site customizations by swizzling React components rendering sidebar items.

```js
{
type: 'doc',
id: 'doc1',
// highlight-start
customProps: {
/* props */
badges: ['new', 'green'],
featured: true,
},
// highlight-end
};
```

Expand Down
8 changes: 6 additions & 2 deletions website/src/components/APITable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ function APITableRow(
id={id}
tabIndex={0}
ref={history.location.hash === anchor ? ref : undefined}
onClick={() => {
history.push(anchor);
onClick={(e) => {
const isLinkClick =
(e.target as HTMLElement).tagName.toUpperCase() === 'A';
if (!isLinkClick) {
history.push(anchor);
}
}}
onKeyDown={(e: React.KeyboardEvent) => {
if (e.key === 'Enter') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Accepted fields:
| `sidebar_label` | `string` | `title` | The text shown in the document sidebar for this document. |
| `sidebar_position` | `number` | Default ordering | Controls the position of a doc inside the generated sidebar slice when using `autogenerated` sidebar items. See also [Autogenerated sidebar metadata](/docs/sidebar#autogenerated-sidebar-metadata). |
| `sidebar_class_name` | `string` | `undefined` | Gives the corresponding sidebar label a special class name when using autogenerated sidebars. |
| `sidebar_custom_props` | `string` | `undefined` | Assign custom metadata to the sidebar item referencing this doc. |
| `sidebar_custom_props` | `object` | `undefined` | Assign [custom props](../../guides/docs/sidebar/index.mdx#passing-custom-props) to the sidebar item referencing this doc |
| `displayed_sidebar` | `string` | `undefined` | Force the display of a given sidebar when browsing the current document. Read the [multiple sidebars guide](../../guides/docs/sidebar/multiple-sidebars.mdx) for details. |
| `hide_title` | `boolean` | `false` | Whether to hide the title at the top of the doc. It only hides a title declared through the front matter, and have no effect on a Markdown title at the top of your document. |
| `hide_table_of_contents` | `boolean` | `false` | Whether to hide the table of contents to the right. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,18 @@ module.exports = {

## Passing custom props {#passing-custom-props}

To pass in custom props to a swizzled sidebar item, add the optional `customProps` object to any of the items:
To pass in custom props to a sidebar item, add the optional `customProps` object to any of the items. This is useful to apply site customizations by swizzling React components rendering sidebar items.

```js
{
type: 'doc',
id: 'doc1',
// highlight-start
customProps: {
/* props */
badges: ['new', 'green'],
featured: true,
},
// highlight-end
};
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Accepted fields:
| `sidebar_label` | `string` | `title` | The text shown in the document sidebar for this document. |
| `sidebar_position` | `number` | Default ordering | Controls the position of a doc inside the generated sidebar slice when using `autogenerated` sidebar items. See also [Autogenerated sidebar metadata](/docs/sidebar#autogenerated-sidebar-metadata). |
| `sidebar_class_name` | `string` | `undefined` | Gives the corresponding sidebar label a special class name when using autogenerated sidebars. |
| `sidebar_custom_props` | `string` | `undefined` | Assign custom metadata to the sidebar item referencing this doc. |
| `sidebar_custom_props` | `object` | `undefined` | Assign [custom props](../../guides/docs/sidebar/index.mdx#passing-custom-props) to the sidebar item referencing this doc |
| `displayed_sidebar` | `string` | `undefined` | Force the display of a given sidebar when browsing the current document. Read the [multiple sidebars guide](../../guides/docs/sidebar/multiple-sidebars.mdx) for details. |
| `hide_title` | `boolean` | `false` | Whether to hide the title at the top of the doc. It only hides a title declared through the front matter, and have no effect on a Markdown title at the top of your document. |
| `hide_table_of_contents` | `boolean` | `false` | Whether to hide the table of contents to the right. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,18 @@ module.exports = {

## Passing custom props {#passing-custom-props}

To pass in custom props to a swizzled sidebar item, add the optional `customProps` object to any of the items:
To pass in custom props to a sidebar item, add the optional `customProps` object to any of the items. This is useful to apply site customizations by swizzling React components rendering sidebar items.

```js
{
type: 'doc',
id: 'doc1',
// highlight-start
customProps: {
/* props */
badges: ['new', 'green'],
featured: true,
},
// highlight-end
};
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Accepted fields:
| `sidebar_label` | `string` | `title` | The text shown in the document sidebar for this document. |
| `sidebar_position` | `number` | Default ordering | Controls the position of a doc inside the generated sidebar slice when using `autogenerated` sidebar items. See also [Autogenerated sidebar metadata](/docs/sidebar#autogenerated-sidebar-metadata). |
| `sidebar_class_name` | `string` | `undefined` | Gives the corresponding sidebar label a special class name when using autogenerated sidebars. |
| `sidebar_custom_props` | `string` | `undefined` | Assign custom metadata to the sidebar item referencing this doc. |
| `sidebar_custom_props` | `object` | `undefined` | Assign [custom props](../../guides/docs/sidebar/index.mdx#passing-custom-props) to the sidebar item referencing this doc |
| `displayed_sidebar` | `string` | `undefined` | Force the display of a given sidebar when browsing the current document. Read the [multiple sidebars guide](../../guides/docs/sidebar/multiple-sidebars.mdx) for details. |
| `hide_title` | `boolean` | `false` | Whether to hide the title at the top of the doc. It only hides a title declared through the front matter, and have no effect on a Markdown title at the top of your document. |
| `hide_table_of_contents` | `boolean` | `false` | Whether to hide the table of contents to the right. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,18 @@ module.exports = {

## Passing custom props {#passing-custom-props}

To pass in custom props to a swizzled sidebar item, add the optional `customProps` object to any of the items:
To pass in custom props to a sidebar item, add the optional `customProps` object to any of the items. This is useful to apply site customizations by swizzling React components rendering sidebar items.

```js
{
type: 'doc',
id: 'doc1',
// highlight-start
customProps: {
/* props */
badges: ['new', 'green'],
featured: true,
},
// highlight-end
};
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Accepted fields:
| `sidebar_label` | `string` | `title` | The text shown in the document sidebar for this document. |
| `sidebar_position` | `number` | Default ordering | Controls the position of a doc inside the generated sidebar slice when using `autogenerated` sidebar items. See also [Autogenerated sidebar metadata](/docs/sidebar#autogenerated-sidebar-metadata). |
| `sidebar_class_name` | `string` | `undefined` | Gives the corresponding sidebar label a special class name when using autogenerated sidebars. |
| `sidebar_custom_props` | `string` | `undefined` | Assign custom metadata to the sidebar item referencing this doc. |
| `sidebar_custom_props` | `object` | `undefined` | Assign [custom props](../../guides/docs/sidebar/index.mdx#passing-custom-props) to the sidebar item referencing this doc |
| `displayed_sidebar` | `string` | `undefined` | Force the display of a given sidebar when browsing the current document. Read the [multiple sidebars guide](../../guides/docs/sidebar/multiple-sidebars.mdx) for details. |
| `hide_title` | `boolean` | `false` | Whether to hide the title at the top of the doc. It only hides a title declared through the front matter, and have no effect on a Markdown title at the top of your document. |
| `hide_table_of_contents` | `boolean` | `false` | Whether to hide the table of contents to the right. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,18 @@ module.exports = {

## Passing custom props {#passing-custom-props}

To pass in custom props to a swizzled sidebar item, add the optional `customProps` object to any of the items:
To pass in custom props to a sidebar item, add the optional `customProps` object to any of the items. This is useful to apply site customizations by swizzling React components rendering sidebar items.

```js
{
type: 'doc',
id: 'doc1',
// highlight-start
customProps: {
/* props */
badges: ['new', 'green'],
featured: true,
},
// highlight-end
};
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Accepted fields:
| `sidebar_label` | `string` | `title` | The text shown in the document sidebar for this document. |
| `sidebar_position` | `number` | Default ordering | Controls the position of a doc inside the generated sidebar slice when using `autogenerated` sidebar items. See also [Autogenerated sidebar metadata](/docs/sidebar#autogenerated-sidebar-metadata). |
| `sidebar_class_name` | `string` | `undefined` | Gives the corresponding sidebar label a special class name when using autogenerated sidebars. |
| `sidebar_custom_props` | `string` | `undefined` | Assign custom metadata to the sidebar item referencing this doc. |
| `sidebar_custom_props` | `object` | `undefined` | Assign [custom props](../../guides/docs/sidebar/index.mdx#passing-custom-props) to the sidebar item referencing this doc |
| `displayed_sidebar` | `string` | `undefined` | Force the display of a given sidebar when browsing the current document. Read the [multiple sidebars guide](../../guides/docs/sidebar/multiple-sidebars.mdx) for details. |
| `hide_title` | `boolean` | `false` | Whether to hide the title at the top of the doc. It only hides a title declared through the front matter, and have no effect on a Markdown title at the top of your document. |
| `hide_table_of_contents` | `boolean` | `false` | Whether to hide the table of contents to the right. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,18 @@ module.exports = {

## Passing custom props {#passing-custom-props}

To pass in custom props to a swizzled sidebar item, add the optional `customProps` object to any of the items:
To pass in custom props to a sidebar item, add the optional `customProps` object to any of the items. This is useful to apply site customizations by swizzling React components rendering sidebar items.

```js
{
type: 'doc',
id: 'doc1',
// highlight-start
customProps: {
/* props */
badges: ['new', 'green'],
featured: true,
},
// highlight-end
};
```

Expand Down

0 comments on commit 1458689

Please sign in to comment.