-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from primer/rezrah/add-related-content-support
Add related content support and navigation using keywords
- Loading branch information
Showing
14 changed files
with
185 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/doctocat-nextjs': patch | ||
--- | ||
|
||
Added OpenGraph tags for improved social sharing experience. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
'@primer/doctocat-nextjs': patch | ||
--- | ||
|
||
Enabled related content navigation using `keywords` and `related` properties in Markdown frontmatter. | ||
|
||
Example: | ||
|
||
``` | ||
--- | ||
title: Page A | ||
keywords: ['keyword', 'another keyword'] | ||
--- | ||
``` | ||
|
||
``` | ||
--- | ||
title: Page B | ||
keywords: ['keyword', 'another keyword'] | ||
--- | ||
``` | ||
|
||
The matching keyword values above across both pages, will enable automatic related content navigation between the two pages. | ||
|
||
or using the `related` property: | ||
|
||
``` | ||
--- | ||
related: [{title: External link example, href: https://example.com}] | ||
--- | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/doctocat-nextjs': patch | ||
--- | ||
|
||
Fixed accessibility violations arising from duplicate landmarks and missing aria labels. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/theme/components/layout/related-content-links/RelatedContentLinks.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.list { | ||
margin-block: var(--base-size-24); | ||
margin-inline-start: 0 !important; | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/theme/components/layout/related-content-links/RelatedContentLinks.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
import {NavList} from '@primer/react' | ||
import {Text, Heading, UnorderedList, InlineLink} from '@primer/react-brand' | ||
import {MdxFile} from 'nextra' | ||
|
||
import styles from './RelatedContentLinks.module.css' | ||
import Link from 'next/link' | ||
import {LinkExternalIcon} from '@primer/octicons-react' | ||
|
||
export type RelatedContentLink = MdxFile & { | ||
title: string | ||
} | ||
|
||
export type RelatedContentLinksProps = { | ||
links: RelatedContentLink[] | ||
} | ||
|
||
export function RelatedContentLinks({links}: RelatedContentLinksProps) { | ||
if (!links.length) return null | ||
|
||
return ( | ||
<div className="custom-component"> | ||
<Heading as="h2">Related content</Heading> | ||
<UnorderedList className={styles.list}> | ||
{links.map(page => ( | ||
<UnorderedList.Item key={page.route}> | ||
<InlineLink href={page.route}>{page.title}</InlineLink>{' '} | ||
{page.route.startsWith('http') ? <LinkExternalIcon /> : null} | ||
</UnorderedList.Item> | ||
))} | ||
</UnorderedList> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters