Skip to content

Commit 19a817c

Browse files
committed
make utm_source env. dependent
1 parent 0554ee4 commit 19a817c

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dist.zip
88
./dist
99
.DS_Store
1010
yarn.lock
11-
.vscode
11+
.vscode
12+
builds/

App.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import PostCard from './components/PostCard'
77
import Loader from './components/Loader'
88

99
const baseURL = 'https://hashnode.com'
10+
const browserType = process.env.browser || 'chrome'
11+
const utmVal = (browserType === 'chrome') ? 'chrome_extension' : 'FF_extension'
1012

1113
class App extends Component {
1214
constructor (props) {
@@ -57,12 +59,12 @@ class App extends Component {
5759
return <li className='post' key={index}>
5860
<PostCard post={post} />
5961
</li>
60-
})
62+
}).reverse()
6163

6264
return (
6365
<div id='app'>
6466
<div className='header'>
65-
<a href='https://hashnode.com?utm_source=chrome_extension&utm_medium=extension' className='logo' target='_blank'>
67+
<a href={`https://hashnode.com?utm_source=${utmVal}&utm_medium=extension`} className='logo' target='_blank'>
6668
<img src={require('./images/hn-logo.png')} />
6769
</a>
6870
<div className='nav'>
@@ -78,9 +80,9 @@ class App extends Component {
7880
</div>
7981
<div className='footer'>
8082
<div>
81-
<a href='https://hashnode.com?utm_source=chrome_extension&utm_medium=extension' target='_blank' rel='noopener'>My feed</a> · <span>&copy; 2019</span>
83+
<a href={`https://hashnode.com?utm_source=${utmVal}&utm_medium=extension`} target='_blank' rel='noopener'>My feed</a> · <span>&copy; 2019</span>
8284
</div>
83-
<a href='https://l.hshno.de/chrome-extension-feedback' target='_blank' rel='noopener'>Feedback</a>
85+
<a href='https://hashnode.typeform.com/to/oeFvmK' target='_blank' rel='noopener'>Feedback</a>
8486
</div>
8587
</div>
8688
)

components/PostCard.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const thumbsImage = require('../images/thumbs.png')
44
const commentsImage = require('../images/comments.png')
55
const dummyUserImage = require('../images/dummyUser.png')
66

7+
const browserType = process.env.browser || 'chrome'
8+
const utmVal = (browserType === 'chrome') ? 'chrome_extension' : 'FF_extension'
9+
710
export class PostCard extends Component {
811
getReplacedImage (src) {
912
var newSrc = 'https://cdn.hashnode.com/res/hashnode/image/upload/'
@@ -34,7 +37,7 @@ export class PostCard extends Component {
3437
<a
3538
href={`https://hashnode.com/post/${post.slug}-${
3639
post.cuid
37-
}?utm_source=chrome_extension&utm_medium=extension`}
40+
}?utm_source=${utmVal}&utm_medium=extension`}
3841
target='_blank'
3942
>
4043
<img className='post-cover' src={post.coverImage} width='100%' />
@@ -44,19 +47,19 @@ export class PostCard extends Component {
4447
<a
4548
href={`https://hashnode.com/post/${post.slug}-${
4649
post.cuid
47-
}?utm_source=chrome_extension&utm_medium=extension`}
50+
}?utm_source=${utmVal}&utm_medium=extension`}
4851
target='_blank'
4952
>
5053
<h3 className='post-title'>{post.title}</h3>
51-
<p className='post-desc'>{post.brief.substring(0, 140)}...</p>
54+
{ post.brief && <p className='post-desc'>{post.brief.substring(0, 140)}...</p> }
5255
</a>
5356
<div className='post-footer'>
5457
<a
5558
href={`${
5659
post.author
5760
? 'https://hashnode.com/@' +
5861
post.author.username +
59-
'?utm_source=chrome_extension&utm_medium=extension'
62+
`?utm_source=${utmVal}&utm_medium=extension`
6063
: ''
6164
}`}
6265
target='_blank'
@@ -77,7 +80,7 @@ export class PostCard extends Component {
7780
<a
7881
href={`https://hashnode.com/post/${post.slug}-${
7982
post.cuid
80-
}?utm_source=chrome_extension&utm_medium=extension`}
83+
}?utm_source=${utmVal}&utm_medium=extension`}
8184
target='_blank'
8285
className='reactions'
8386
>
@@ -87,7 +90,7 @@ export class PostCard extends Component {
8790
<a
8891
href={`https://hashnode.com/post/${post.slug}-${
8992
post.cuid
90-
}?utm_source=chrome_extension&utm_medium=extension`}
93+
}?utm_source=${utmVal}&utm_medium=extension`}
9194
target='_blank'
9295
className='comments'
9396
>

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"main": "index.js",
55
"scripts": {
66
"start": "parcel -d dist/web index.html",
7-
"start-chrome": "parcel index.html -d ./dist/dist-chrome",
8-
"build-chrome": "parcel build index.html -d ./builds/chrome && cp -R ./chrome/* ./builds/chrome",
9-
"start-firefox": "parcel index.html -d ./dist/dist-firefox",
10-
"build-firefox": "parcel build index.html -d ./builds/firefox && cp -R ./firefox/* ./builds/firefox",
7+
"start-chrome": "browser=chrome parcel index.html -d ./dist/dist-chrome",
8+
"build-chrome": "browser=chrome parcel build index.html -d ./builds/chrome && cp -R ./chrome/* ./builds/chrome",
9+
"start-firefox": "browser=firefox parcel index.html -d ./dist/dist-firefox",
10+
"build-firefox": "browser=firefox parcel build index.html -d ./builds/firefox && cp -R ./firefox/* ./builds/firefox",
1111
"build-all": "yarn build-chrome && yarn build-firefox",
1212
"test": "standard"
1313
},

0 commit comments

Comments
 (0)