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
@@ -17,31 +17,15 @@ interface Props {
17
17
18
18
export const IntegrationPage = ( { integration} : Props ) => {
19
19
const {
20
- frontmatter : { name, title, excerpt} ,
21
- logo,
20
+ frontmatter : { name, title, excerpt, logoFilename} ,
22
21
content,
23
22
} = integration ;
24
23
25
24
return (
26
25
< 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
- >
26
+ < Box padding = { { vertical : 24 } } flex = { { direction : 'column' , gap : 12 } } >
43
27
< Box flex = { { direction : 'row' , gap : 12 , alignItems : 'flex-start' } } >
44
- < IntegrationIcon name = { name } logo = { logo } />
28
+ < IntegrationIcon name = { name } logoFilename = { logoFilename } />
45
29
< Box flex = { { direction : 'column' , gap : 2 } } margin = { { top : 4 } } >
46
30
< div style = { { fontSize : 18 , fontWeight : 600 } } > { title } </ div >
47
31
< Body color = { Colors . textLight ( ) } > { excerpt } </ Body >
@@ -54,6 +38,7 @@ export const IntegrationPage = ({integration}: Props) => {
54
38
rehypePlugins = { [ [ rehypeHighlight , { ignoreMissing : true } ] ] }
55
39
components = { {
56
40
code : Code ,
41
+ a : Anchor ,
57
42
} }
58
43
>
59
44
{ content }
@@ -64,15 +49,36 @@ export const IntegrationPage = ({integration}: Props) => {
64
49
) ;
65
50
} ;
66
51
67
- const Code : CodeComponent = ( props ) => {
68
- const { children, className, ...rest } = props ;
52
+ const DOCS_ORIGIN = 'https://docs.dagster.io' ;
53
+
54
+ const Anchor : Components [ 'a' ] = ( props ) => {
55
+ const { children, href, ...rest } = props ;
56
+ const finalHref = href ?. startsWith ( '/' ) ? `${ DOCS_ORIGIN } ${ href } ` : href ;
57
+ return (
58
+ < a href = { finalHref } target = "_blank" rel = "noreferrer" { ...rest } >
59
+ { children }
60
+ </ a >
61
+ ) ;
62
+ } ;
63
+
64
+ const Code : Components [ 'code' ] = ( props ) => {
65
+ const { children, className, inline, ...rest } = props ;
66
+
69
67
const codeRef = useRef < HTMLElement > ( null ) ;
70
68
const [ value , setValue ] = useState ( '' ) ;
71
69
72
70
useLayoutEffect ( ( ) => {
73
71
setValue ( codeRef . current ?. textContent ?. trim ( ) ?? '' ) ;
74
72
} , [ children ] ) ;
75
73
74
+ if ( inline ) {
75
+ return (
76
+ < code className = { clsx ( className , styles . inlineCode ) } { ...rest } >
77
+ { children }
78
+ </ code >
79
+ ) ;
80
+ }
81
+
76
82
return (
77
83
< div className = { styles . codeBlock } >
78
84
< code className = { className } { ...rest } ref = { codeRef } >
0 commit comments