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';
33import IconButton from '@mui/material/IconButton' ;
44import CopyToClipboard from 'react-copy-to-clipboard' ;
55import SvgIcon from '@mui/material/SvgIcon' ;
6+ import { urlFormatter } from '../../helpers/url-formatter' ;
67
78const HashTagSvg = ( props ) => (
89 // eslint-disable-next-line max-len
@@ -14,15 +15,19 @@ const HashTagSvg = (props) => (
1415 > </ path >
1516) ;
1617
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+ } ;
2631
2732ShareButton . propTypes = {
2833 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