File tree Expand file tree Collapse file tree 2 files changed +25
-9
lines changed
packages/react-renderer-demo/src Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3
3
import IconButton from '@mui/material/IconButton' ;
4
4
import CopyToClipboard from 'react-copy-to-clipboard' ;
5
5
import SvgIcon from '@mui/material/SvgIcon' ;
6
+ import { urlFormatter } from '../../helpers/url-formatter' ;
6
7
7
8
const HashTagSvg = ( props ) => (
8
9
// eslint-disable-next-line max-len
@@ -14,15 +15,19 @@ const HashTagSvg = (props) => (
14
15
> </ path >
15
16
) ;
16
17
17
- const ShareButton = ( { path } ) => (
18
- < CopyToClipboard text = { path } >
19
- < IconButton size = "medium" >
20
- < SvgIcon fontSize = "small" viewBox = "0 0 48 48" >
21
- < HashTagSvg />
22
- </ SvgIcon >
23
- </ IconButton >
24
- </ CopyToClipboard >
25
- ) ;
18
+ const ShareButton = ( { path } ) => {
19
+ console . log ( process . env . NEXT_PUBLIC_VAR_VAL ) ;
20
+
21
+ return (
22
+ < CopyToClipboard text = { urlFormatter ( path ) } >
23
+ < IconButton size = "medium" >
24
+ < SvgIcon fontSize = "small" viewBox = "0 0 48 48" >
25
+ < HashTagSvg />
26
+ </ SvgIcon >
27
+ </ IconButton >
28
+ </ CopyToClipboard >
29
+ ) ;
30
+ } ;
26
31
27
32
ShareButton . propTypes = {
28
33
path : PropTypes . string . isRequired ,
Original file line number Diff line number Diff line change
1
+ export const urlFormatter = ( initPath ) => {
2
+ const env = process . env . NEXT_PUBLIC_VERCEL_ENV ;
3
+ const url = process . env . NEXT_PUBLIC_VERCEL_URL ;
4
+ const branchUrl = process . env . NEXT_PUBLIC_VERCEL_BRANCH_URL ;
5
+
6
+ if ( env === 'preview' ) {
7
+ return `https://${ branchUrl + initPath } ` ;
8
+ }
9
+
10
+ return `https://${ url + initPath } ` ;
11
+ } ;
You can’t perform that action at this time.
0 commit comments