Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
13 changes: 11 additions & 2 deletions docs/contributing/pages/components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,25 @@ See also the [Alert component](#alert).

## PageGrid

Render all child pages of this document, including their `description` if available.
Render all `next_steps` of this document or default child pages, including their `description` if available.

You can specify `next_steps` in the frontmatter of a page to include them in the grid. It supports relative paths and will automatically resolve them.

```markdown {tabTitle:Example}
---
# in the frontmatter of a page:
next_steps:
- ./child-one
- ./child-two
- ../parent/child-three
---

<PageGrid />
```

Attributes:

- `header` (string) - optional header value to include, rendered as an H2
- `nextPages` (boolean) - only render pages which come next based on sidebar ordering

## PlatformContent

Expand Down
2 changes: 0 additions & 2 deletions docs/platforms/php/guides/laravel/other-versions/laravel4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,3 @@ If you wish to wire up Sentry anywhere outside of the standard error handlers, o
```php
$app['sentry']->setRelease(Git::sha());
```

<PageGrid nextPages header="Next Steps" />
2 changes: 0 additions & 2 deletions docs/platforms/php/guides/laravel/other-versions/laravel5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,3 @@ You most likely don't want errors to be sent to Sentry when you are developing o
You can also do this by not defining `SENTRY_LARAVEL_DSN` in your `.env` or by defining it as `SENTRY_LARAVEL_DSN=null`.

If you do leave Sentry enabled when developing or running tests, it's possible for it to have a negative effect on the performance of your application or test suite.

<PageGrid nextPages header="Next Steps" />
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,3 @@ You most likely don't want errors to be sent to Sentry when you are developing o
You can also do this by not defining `SENTRY_LARAVEL_DSN` in your `.env` or by defining it as `SENTRY_LARAVEL_DSN=null`.

If you do leave Sentry enabled when developing or running tests, it's possible for it to have a negative effect on the performance of your application or test suite.

<PageGrid nextPages header="Next Steps" />
2 changes: 0 additions & 2 deletions docs/platforms/php/guides/laravel/other-versions/lumen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,3 @@ You most likely don't want errors to be sent to Sentry when you are developing o
You can also do this by not defining `SENTRY_LARAVEL_DSN` in your `.env` or by defining it as `SENTRY_LARAVEL_DSN=null`.

If you do leave Sentry enabled when developing or running tests, it's possible for it to have a negative effect on the performance of your application or test suite.

<PageGrid nextPages header="Next Steps" />
25 changes: 14 additions & 11 deletions src/components/pageGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
import path from 'path';

import Link from 'next/link';

import {nodeForPath} from 'sentry-docs/docTree';
import {DocNode, nodeForPath} from 'sentry-docs/docTree';
import {serverContext} from 'sentry-docs/serverContext';
import {isTruthy} from 'sentry-docs/utils';

type Props = {
nextPages: boolean;
/**
* A list of pages to exclude from the grid.
* Specify the file name of the page, for example, "index" for "index.mdx"
*/
exclude?: string[];
header?: string;
};

export function PageGrid({header}: Props) {
const {rootNode, path} = serverContext();
const {rootNode, path: nodePath} = serverContext();
if (!rootNode) {
return null;
}

const parentNode = nodeForPath(rootNode, path);
if (!parentNode) {
const parentNode = nodeForPath(rootNode, nodePath);
if (!parentNode || parentNode.children.length === 0) {
return null;
}

const children: DocNode[] = parentNode.frontmatter.next_steps?.length
? parentNode.frontmatter.next_steps
.map(p => nodeForPath(rootNode, path.join(parentNode.path, p)))
.filter(isTruthy) ?? []
: parentNode.children;

return (
<nav>
{header && <h2>{header}</h2>}
<ul>
{parentNode.children
{children
/* NOTE: temp fix while we figure out the reason why some nodes have empty front matter */
.filter(c => c.frontmatter.title)
.map(n => (
Expand Down
8 changes: 7 additions & 1 deletion src/types/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ export interface FrontMatter {
* A list of keywords for indexing with search.
*/
keywords?: string[];
/**
* relative links to use in the "next steps" section of the page grid
* takes precendence over children when present
*/
next_steps?: string[];
/**
* Set this to true to disable indexing (robots, algolia) of this content.
*/
noindex?: boolean;

/**
* Specific guides that this page is not relevant to.
*/
Expand All @@ -45,8 +51,8 @@ export interface FrontMatter {
* optional sidebar title
*/
sidebar_title?: string;

sourcePath?: string;

/**
* Specific guides that this page is relevant to.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import qs from 'query-string';

/**
* This function is used to filter out any elements that are not truthy and plays nice with TypeScript.
* @param x - The value to check for truthiness.
* @example
* ```typeScript
* let numbers: number[] = [1, undefined, 3, null, 5].filter(isTruthy);
* ```
*/
export const isTruthy = <T>(x?: T): x is Exclude<T, null | undefined> => {
return x !== null && x !== undefined;
};

export function sortBy<A>(arr: A[], comp: (v: A) => number): A[] {
return arr.sort((a, b) => {
const aComp = comp(a);
Expand Down