Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions .changeset/shiny-clocks-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@primer/gatsby-theme-doctocat": patch
---

- Updated external links in frontmatter to open in new tab
- Added support for Figma links in frontmatter
32 changes: 32 additions & 0 deletions theme/src/components/figma-link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {Link, Text} from '@primer/react'
import React from 'react'

function SourceLink({href}) {
return (
<Link href={href} target="_blank">
<FigmaLogo />
<Text sx={{ml: 2, display: 'inline-block'}}>View Figma</Text>
</Link>
)
}

function FigmaLogo() {
return (
<svg
width={16}
height={16}
aria-hidden="true"
style={{verticalAlign: 'text-bottom'}}
fill="none"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 172 247"
>
<g stroke="currentColor" strokeWidth="15.081">
<path d="M164 46.5c0 21.263-17.237 38.5-38.5 38.5H86V8h39.5C146.763 8 164 25.237 164 46.5ZM8 46.5C8 67.763 25.237 85 46.5 85H86V8H46.5C25.237 8 8 25.237 8 46.5ZM8 123.501c0 21.263 17.237 38.5 38.5 38.5H86v-77H46.5c-21.263 0-38.5 17.237-38.5 38.5Z" />
<path d="M8 200.5C8 221.763 25.485 239 46.748 239 68.288 239 86 221.539 86 200v-38H46.5C25.237 162 8 179.237 8 200.5ZM86 123.501c0 21.263 17.237 38.5 38.5 38.5h1c21.263 0 38.5-17.237 38.5-38.5s-17.237-38.5-38.5-38.5h-1c-21.263 0-38.5 17.237-38.5 38.5Z" />
</g>
</svg>
)
}

export default SourceLink
5 changes: 4 additions & 1 deletion theme/src/components/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import Sidebar from './sidebar'
import SourceLink from './source-link'
import StatusLabel from './status-label'
import StorybookLink from './storybook-link'
import FigmaLink from './figma-link'
import TableOfContents from './table-of-contents'

function Layout({children, pageContext}) {
let {title, description, status, source, storybook, additionalContributors, componentId} = pageContext.frontmatter
let {title, description, figma, status, source, storybook, additionalContributors, componentId} =
pageContext.frontmatter

if (!additionalContributors) {
additionalContributors = []
Expand Down Expand Up @@ -84,6 +86,7 @@ function Layout({children, pageContext}) {
>
{source ? <SourceLink href={source} /> : null}
{storybook ? <StorybookLink href={storybook} /> : null}
{figma ? <FigmaLink href={figma} /> : null}
</Box>
) : null}
</Box>
Expand Down
2 changes: 1 addition & 1 deletion theme/src/components/source-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'

function SourceLink({href}) {
return (
<Link href={href}>
<Link href={href} target="_blank">
<MarkGithubIcon />
<Text sx={{ml: 2, display: 'inline-block'}}>View source</Text>
</Link>
Expand Down
4 changes: 2 additions & 2 deletions theme/src/components/storybook-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React from 'react'

function SourceLink({href}) {
return (
<Link href={href}>
<Link href={href} target="_blank">
<StorybookIcon />
<Text sx={{ml: 2, display: 'inline-block'}}>View storybook</Text>
<Text sx={{ml: 2, display: 'inline-block'}}>View Storybook</Text>
</Link>
)
}
Expand Down