Skip to content

fix(components): Re-add exclude functionality in PageGrid #11510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 26 additions & 29 deletions docs/contributing/pages/components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ See also the [Note component](#note).

Render an expandable section.

<Expandable title="This is a title">
This is some content
</Expandable>
<Expandable title="This is a title">This is some content</Expandable>

```markdown {tabTitle:Example}
<Expandable title="This is a title">
Expand Down Expand Up @@ -110,6 +108,7 @@ You can also highlight diffs using the `diff` language:
+ plus one
```
````

If you want to preserve syntax highlighting, you can add `diff` metadata to any code block
then annotate the diff with `+` and `-`:

Expand Down Expand Up @@ -193,6 +192,7 @@ Attributes:

- `header` (string) - optional header value to include, rendered as an H2
- `nextPages` (boolean) - only render pages which come next based on sidebar ordering
- `exclude` (string[]) - an array of pages to exclude from the grid. Specify the file name of the page, for example, `"index"` for `index.mdx`.
Copy link
Member Author

@Lms24 Lms24 Oct 8, 2024

Choose a reason for hiding this comment

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

hmm looks like this file wasn't formatted previously. I only added this line, rest of the changes in this file is just auto-format.


## PlatformContent

Expand Down Expand Up @@ -281,15 +281,11 @@ You can specify multiple features by separating them with a comma:

The range visibility will be controlled by the `OnboardingOptionButtons` component:

````jsx diff
```jsx diff
<OnboardingOptionButtons
options={[
'error-monitoring',
"profiling",
"performance",
]}
options={["error-monitoring", "profiling", "performance"]}
/>
````
```

- `options` can either be either an object of this shape:

Expand All @@ -300,22 +296,20 @@ The range visibility will be controlled by the `OnboardingOptionButtons` compone
checked: boolean
}
```

or a string (one of these `id`s 👆) for convenience when using defaults.

<Alert level="warning" title="Important">
The underlying implementation relies on the `onboardingOptions` metadata in the code blocks to be valid JSON syntax.
The underlying implementation relies on the `onboardingOptions` metadata in
the code blocks to be valid JSON syntax.
</Alert>

- default values: `checked: false` and `disabled: false` (`true` for `error-monitoring`).

Example (output of the above):

<OnboardingOptionButtons
options={[
"error-monitoring",
"performance",
"profiling",
]}
options={["error-monitoring", "performance", "profiling"]}
dontStick
/>

Expand Down Expand Up @@ -367,29 +361,32 @@ Or you can use the `hideForThisOption` prop to hide the content for the selected
Hide this section for `profiling` option.
</OnboardingOption>
```
``````
````

Example:

- toggle the `performance` option above to see the effect:

<OnboardingOption optionId="performance">

```jsx
<OnboardingOption optionId="performance">
This code block is wrapped in a `OnboardingOption` component and will only
be rendered when the `performance` option is selected.
</OnboardingOption>
```
```jsx
<OnboardingOption optionId="performance">
This code block is wrapped in a `OnboardingOption` component and will only
be rendered when the `performance` option is selected.
</OnboardingOption>
```

</OnboardingOption>

- toggle the `profiling` option above to see the effect:

<OnboardingOption optionId="profiling" hideForThisOption>

```jsx
<OnboardingOption optionId="profiling" hideForThisOption>
This code block is wrapped in a `OnboardingOption` component and will only
be rendered when the `profiling` option is NOT selected.
</OnboardingOption>
```
```jsx
<OnboardingOption optionId="profiling" hideForThisOption>
This code block is wrapped in a `OnboardingOption` component and will only
be rendered when the `profiling` option is NOT selected.
</OnboardingOption>
```

</OnboardingOption>
4 changes: 2 additions & 2 deletions src/components/pageGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {
header?: string;
};

export function PageGrid({header}: Props) {
export function PageGrid({header, exclude}: Props) {
const {rootNode, path} = serverContext();

const parentNode = nodeForPath(rootNode, path);
Expand All @@ -27,7 +27,7 @@ export function PageGrid({header}: Props) {
<ul>
{parentNode.children
/* NOTE: temp fix while we figure out the reason why some nodes have empty front matter */
.filter(c => c.frontmatter.title)
.filter(c => c.frontmatter.title && !exclude?.includes(c.slug))
.sort((a, b) => sidebarOrderSorter(a.frontmatter, b.frontmatter))
.map(n => (
<li key={n.path} style={{marginBottom: '1rem'}}>
Expand Down
Loading