-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: links to docs, doc page and story
- Loading branch information
1 parent
7aa9497
commit 892416d
Showing
9 changed files
with
111 additions
and
4 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { FC, useContext } from 'react'; | ||
import { LinkProps } from 'theme-ui'; | ||
import { Link } from '@component-controls/app-components'; | ||
import { BlockContext } from '@component-controls/blocks'; | ||
|
||
export interface DocLinkProps { | ||
id: string; | ||
} | ||
/** | ||
* native lonk to a documentation page | ||
*/ | ||
export const DocLink: FC<DocLinkProps & Omit<LinkProps, 'href'>> = ({ | ||
children, | ||
id, | ||
...props | ||
}) => { | ||
const { storeProvider } = useContext(BlockContext); | ||
const href = storeProvider.getDocPath(id); | ||
return ( | ||
<Link href={href} {...props}> | ||
{children} | ||
</Link> | ||
); | ||
}; |
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,22 @@ | ||
import React, { FC, useContext } from 'react'; | ||
import { LinkProps } from 'theme-ui'; | ||
import { Link } from '@component-controls/app-components'; | ||
import { BlockContext } from '@component-controls/blocks'; | ||
|
||
/** | ||
* native lonk to the documentation | ||
*/ | ||
export const DocsLink: FC<Omit<LinkProps, 'href'>> = ({ | ||
children, | ||
...props | ||
}) => { | ||
const { storeProvider } = useContext(BlockContext); | ||
const config = storeProvider.config; | ||
const { basePath = '' } = config?.options || {}; | ||
|
||
return ( | ||
<Link href={basePath} {...props}> | ||
{children} | ||
</Link> | ||
); | ||
}; |
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,25 @@ | ||
import React, { FC, useContext } from 'react'; | ||
import { LinkProps } from 'theme-ui'; | ||
import { Link } from '@component-controls/app-components'; | ||
import { BlockContext } from '@component-controls/blocks'; | ||
|
||
export interface StoryLinkProps { | ||
id: string; | ||
} | ||
/** | ||
* native lonk to a story | ||
*/ | ||
export const StoryLink: FC<StoryLinkProps & Omit<LinkProps, 'href'>> = ({ | ||
children, | ||
id, | ||
...props | ||
}) => { | ||
const { storeProvider } = useContext(BlockContext); | ||
const story = storeProvider.getStory(id); | ||
const href = story ? storeProvider.getStoryPath(story.id || '') : ''; | ||
return ( | ||
<Link href={href} {...props}> | ||
{children} | ||
</Link> | ||
); | ||
}; |
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,3 @@ | ||
export * from './DocLink'; | ||
export * from './DocsLink'; | ||
export * from './StoryLink'; |
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