1
- import { Body , Box , Colors , Heading , PageHeader } from '@dagster-io/ui-components' ;
1
+ import { Body , Box , Colors } from '@dagster-io/ui-components' ;
2
+ import clsx from 'clsx' ;
2
3
import { useLayoutEffect , useRef , useState } from 'react' ;
3
4
import ReactMarkdown from 'react-markdown' ;
4
- import { CodeComponent } from 'react-markdown/lib/ast-to-react' ;
5
- import { Link } from 'react-router-dom' ;
5
+ import { Components } from 'react-markdown/lib/ast-to-react' ;
6
6
import rehypeHighlight from 'rehype-highlight' ;
7
7
import remarkGfm from 'remark-gfm' ;
8
8
@@ -24,22 +24,7 @@ export const IntegrationPage = ({integration}: Props) => {
24
24
25
25
return (
26
26
< div >
27
- < PageHeader
28
- title = {
29
- < Heading >
30
- < Box flex = { { direction : 'row' , gap : 8 } } >
31
- < Link to = "/integrations" > Integrations Marketplace</ Link >
32
- < span > / </ span >
33
- < div > { title } </ div >
34
- </ Box >
35
- </ Heading >
36
- }
37
- />
38
- < Box
39
- padding = { { vertical : 24 } }
40
- flex = { { direction : 'column' , gap : 24 } }
41
- style = { { width : '1100px' , margin : '0 auto' } }
42
- >
27
+ < Box padding = { { vertical : 24 } } flex = { { direction : 'column' , gap : 12 } } >
43
28
< Box flex = { { direction : 'row' , gap : 12 , alignItems : 'flex-start' } } >
44
29
< IntegrationIcon name = { name } logo = { logo } />
45
30
< Box flex = { { direction : 'column' , gap : 2 } } margin = { { top : 4 } } >
@@ -54,6 +39,7 @@ export const IntegrationPage = ({integration}: Props) => {
54
39
rehypePlugins = { [ [ rehypeHighlight , { ignoreMissing : true } ] ] }
55
40
components = { {
56
41
code : Code ,
42
+ a : Anchor ,
57
43
} }
58
44
>
59
45
{ content }
@@ -64,15 +50,36 @@ export const IntegrationPage = ({integration}: Props) => {
64
50
) ;
65
51
} ;
66
52
67
- const Code : CodeComponent = ( props ) => {
68
- const { children, className, ...rest } = props ;
53
+ const DOCS_ORIGIN = 'https://docs.dagster.io' ;
54
+
55
+ const Anchor : Components [ 'a' ] = ( props ) => {
56
+ const { children, href, ...rest } = props ;
57
+ const finalHref = href ?. startsWith ( '/' ) ? `${ DOCS_ORIGIN } ${ href } ` : href ;
58
+ return (
59
+ < a href = { finalHref } target = "_blank" rel = "noreferrer" { ...rest } >
60
+ { children }
61
+ </ a >
62
+ ) ;
63
+ } ;
64
+
65
+ const Code : Components [ 'code' ] = ( props ) => {
66
+ const { children, className, inline, ...rest } = props ;
67
+
69
68
const codeRef = useRef < HTMLElement > ( null ) ;
70
69
const [ value , setValue ] = useState ( '' ) ;
71
70
72
71
useLayoutEffect ( ( ) => {
73
72
setValue ( codeRef . current ?. textContent ?. trim ( ) ?? '' ) ;
74
73
} , [ children ] ) ;
75
74
75
+ if ( inline ) {
76
+ return (
77
+ < code className = { clsx ( className , styles . inlineCode ) } { ...rest } >
78
+ { children }
79
+ </ code >
80
+ ) ;
81
+ }
82
+
76
83
return (
77
84
< div className = { styles . codeBlock } >
78
85
< code className = { className } { ...rest } ref = { codeRef } >
0 commit comments