Skip to content

Commit 2704c6a

Browse files
adding loggers to see vercel env variables
1 parent 5b9f8ea commit 2704c6a

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

packages/react-renderer-demo/src/components/mdx/share-button.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ const HashTagSvg = (props) => (
1515
></path>
1616
);
1717

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-
};
18+
const ShareButton = ({ path }) => (
19+
<CopyToClipboard text={urlFormatter(path)}>
20+
<IconButton size="medium">
21+
<SvgIcon fontSize="small" viewBox="0 0 48 48">
22+
<HashTagSvg />
23+
</SvgIcon>
24+
</IconButton>
25+
</CopyToClipboard>
26+
);
3127

3228
ShareButton.propTypes = {
3329
path: PropTypes.string.isRequired,

packages/react-renderer-demo/src/helpers/url-formatter.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
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;
2+
const nextEnv = process.env.NEXT_PUBLIC_VERCEL_ENV;
3+
const nextUrl = process.env.NEXT_PUBLIC_VERCEL_URL;
4+
const nextBranchUrl = process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL;
55

6-
if (env === 'preview') {
6+
const env = process.env.VERCEL_ENV;
7+
const url = process.env.VERCEL_URL;
8+
const branchUrl = process.env.VERCEL_BRANCH_URL;
9+
10+
console.log(`NEXT_PUBLIC_VERCEL_ENV= ${nextEnv}, NEXT_PUBLIC_VERCEL_URL= ${nextUrl}, NEXT_PUBLIC_VERCEL_BRANCH_URL= ${nextBranchUrl}`);
11+
console.log(`VERCEL_ENV= ${env}, VERCEL_URL= ${url}, VERCEL_BRANCH_URL= ${branchUrl}`);
12+
13+
if (env === 'preview' || nextEnv === 'preview') {
714
return `https://${branchUrl + initPath}`;
815
}
916

0 commit comments

Comments
 (0)