sfc-utils 1.4.29 → 1.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/appcheck.js +28 -0
- package/components/byline.mjs +46 -46
- package/components/sharebuttons.mjs +57 -44
- package/index.js +1 -27
- package/package.json +1 -1
package/appcheck.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Check to see if this should serve the app version of the project
|
|
2
|
+
let appCheck = function(){
|
|
3
|
+
// Save current env
|
|
4
|
+
const env = process.env.GATSBY_DEPLOY_ENV
|
|
5
|
+
|
|
6
|
+
let appVersion = false
|
|
7
|
+
// If env reports app, then it's app by default
|
|
8
|
+
if (env === 'app'){
|
|
9
|
+
appVersion = true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// If we can access window, check to see if we're dealing with app version
|
|
13
|
+
if (typeof window !== "undefined"){
|
|
14
|
+
// Any link with ?fromRichie=1 will have paywall disabled
|
|
15
|
+
// Also hdnEmployeeAccess is the new free param
|
|
16
|
+
// Native in-app webviews will have a custom user agent, so check that too
|
|
17
|
+
if (
|
|
18
|
+
window.location.href.indexOf('fromRichie=1') > -1 ||
|
|
19
|
+
window.location.href.indexOf('hdnEmployeeAccess=true') > -1 ||
|
|
20
|
+
navigator.userAgent.indexOf(' Richie/') > -1) {
|
|
21
|
+
appVersion = true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return appVersion
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = { appCheck }
|
package/components/byline.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import Authors from './authors.mjs'
|
|
3
3
|
import ShareButtons from './sharebuttons.mjs'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
pubdateString,
|
|
7
|
+
moddateString,
|
|
8
8
|
} from './helpers/datehelpers.mjs'
|
|
9
9
|
|
|
10
10
|
const Byline = ({ meta }) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const {
|
|
12
|
+
PROJECT: { AUTHORS, ISO_MODDATE, ISO_PUBDATE },
|
|
13
|
+
} = meta
|
|
14
|
+
const has_authors = AUTHORS[0].AUTHOR_NAME !== ""
|
|
15
15
|
|
|
16
|
-
return (
|
|
16
|
+
return (
|
|
17
17
|
<>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
<div className="byline-wrapper">
|
|
19
|
+
<div className="byline">
|
|
20
|
+
{has_authors &&
|
|
21
|
+
<>
|
|
22
22
|
<span>By</span>
|
|
23
23
|
{AUTHORS.map((author, index) => {
|
|
24
24
|
// Pass special flag if this is the last item
|
|
@@ -37,43 +37,43 @@ return (
|
|
|
37
37
|
/>
|
|
38
38
|
)
|
|
39
39
|
})}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{ has_authors && <span> | </span> }
|
|
40
|
+
</>
|
|
41
|
+
}
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
43
|
+
{has_authors && <span> | </span>}
|
|
44
|
+
|
|
45
|
+
{!moddateString &&
|
|
46
|
+
<>
|
|
47
|
+
|
|
48
|
+
<time
|
|
49
|
+
className="topper-dateline"
|
|
50
|
+
dateTime={ISO_PUBDATE}
|
|
51
|
+
itemProp="datePublished"
|
|
52
|
+
>
|
|
53
|
+
{!has_authors && <span>Published </span>} {pubdateString}
|
|
54
|
+
</time>
|
|
55
|
+
</>
|
|
56
|
+
}
|
|
57
|
+
{moddateString && (
|
|
58
|
+
<>
|
|
59
|
+
<time
|
|
60
|
+
className="topper-dateline updated-date"
|
|
61
|
+
dateTime={ISO_MODDATE}
|
|
62
|
+
itemProp="dateModified"
|
|
63
|
+
>
|
|
64
|
+
Updated {moddateString}
|
|
65
|
+
</time>
|
|
66
|
+
</>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
<div className="articleHeader--shareTools">
|
|
70
|
+
<div className="share-list" id="sharebutton-wrapper">
|
|
71
|
+
<ShareButtons meta={meta} />
|
|
72
|
+
</div>
|
|
74
73
|
</div>
|
|
74
|
+
</div>
|
|
75
75
|
</>
|
|
76
|
-
|
|
76
|
+
)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export default Byline
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, {useEffect, useState} from 'react'
|
|
2
2
|
import * as shareStyles from '../styles/modules/share.module.less'
|
|
3
|
+
import { appCheck } from '../appcheck.js'
|
|
3
4
|
|
|
4
5
|
const ShareButtons = ({ meta, urlAdd }) => {
|
|
6
|
+
// We need to run appCheck in useEffect because we need to wait for the DOM to be ready
|
|
7
|
+
let [hideSocial, setHideSocial] = useState(false)
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (appCheck()) {
|
|
10
|
+
setHideSocial(true)
|
|
11
|
+
}
|
|
12
|
+
}, [])
|
|
13
|
+
|
|
5
14
|
// Extension to URL if passed in
|
|
6
15
|
if (!urlAdd) {
|
|
7
16
|
urlAdd = ''
|
|
@@ -22,49 +31,53 @@ const ShareButtons = ({ meta, urlAdd }) => {
|
|
|
22
31
|
|
|
23
32
|
return (
|
|
24
33
|
<div className={shareStyles.wrapper} id="sharebutton-box">
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
34
|
+
{!hideSocial &&
|
|
35
|
+
<>
|
|
36
|
+
{/* Twitter */}
|
|
37
|
+
<a
|
|
38
|
+
href={`https://twitter.com/intent/tweet?url=${meta.MAIN_DOMAIN}%2F${subfolder}${meta.PROJECT.SLUG}%2F${urlAdd}&text=${meta.PROJECT.TWITTER_TEXT}`}
|
|
39
|
+
className={shareStyles.link}
|
|
40
|
+
>
|
|
41
|
+
<svg
|
|
42
|
+
className={shareStyles.svg}
|
|
43
|
+
data-icon="twitter"
|
|
44
|
+
role="img"
|
|
45
|
+
aria-hidden="true"
|
|
46
|
+
focusable="false"
|
|
47
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
48
|
+
viewBox="0 0 248 204"
|
|
49
|
+
>
|
|
50
|
+
<path
|
|
51
|
+
data-name="Twitter Logo"
|
|
52
|
+
fill="currentColor"
|
|
53
|
+
d="M222 51.29c.15 2.16.15 4.34.15 6.52 0 66.74-50.8 143.69-143.69 143.69A142.91 142.91 0 0 1 1 178.82a102.72 102.72 0 0 0 12 .72 101.29 101.29 0 0 0 62.72-21.66 50.53 50.53 0 0 1-47.18-35.07 50.35 50.35 0 0 0 22.8-.86 50.53 50.53 0 0 1-40.52-49.5v-.64a50.25 50.25 0 0 0 22.92 6.32 50.55 50.55 0 0 1-15.6-67.42 143.38 143.38 0 0 0 104.08 52.77 50.55 50.55 0 0 1 86.06-46.06 101.19 101.19 0 0 0 32.06-12.26 50.66 50.66 0 0 1-22.2 27.93 100.89 100.89 0 0 0 29-7.94A102.84 102.84 0 0 1 222 51.29z"
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
</a>
|
|
57
|
+
{/* Facebook */}
|
|
58
|
+
<a
|
|
59
|
+
href={`https://www.facebook.com/sharer/sharer.php?u=${meta.MAIN_DOMAIN}%2F${subfolder}${meta.PROJECT.SLUG}%2F${urlAdd}`}
|
|
60
|
+
className={shareStyles.link}
|
|
61
|
+
onClick={facebookClick}
|
|
62
|
+
>
|
|
63
|
+
<svg
|
|
64
|
+
className={shareStyles.svg}
|
|
65
|
+
aria-hidden="true"
|
|
66
|
+
focusable="false"
|
|
67
|
+
data-prefix="fab"
|
|
68
|
+
data-icon="facebook"
|
|
69
|
+
role="img"
|
|
70
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
71
|
+
viewBox="0 0 320 512"
|
|
72
|
+
>
|
|
73
|
+
<path
|
|
74
|
+
fill="currentColor"
|
|
75
|
+
d="M279.14 288l14.22-92.66h-88.91v-60.13c0-25.35 12.42-50.06 52.24-50.06h40.42V6.26S260.43 0 225.36 0c-73.22 0-121.08 44.38-121.08 124.72v70.62H22.89V288h81.39v224h100.17V288z"
|
|
76
|
+
></path>
|
|
77
|
+
</svg>
|
|
78
|
+
</a>
|
|
79
|
+
</>
|
|
80
|
+
}
|
|
68
81
|
{/* Email */}
|
|
69
82
|
<a
|
|
70
83
|
href={`mailto:?subject=${meta.PROJECT.TITLE}&body=${meta.PROJECT.DESCRIPTION}%0A%0A${meta.MAIN_DOMAIN}%2F${subfolder}${meta.PROJECT.SLUG}%2F${urlAdd}`}
|
package/index.js
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Check to see if this should serve the app version of the project
|
|
3
|
-
let appCheck = function(){
|
|
4
|
-
// Save current env
|
|
5
|
-
const env = process.env.GATSBY_DEPLOY_ENV
|
|
6
|
-
|
|
7
|
-
let appVersion = false
|
|
8
|
-
// If env reports app, then it's app by default
|
|
9
|
-
if (env === 'app'){
|
|
10
|
-
appVersion = true
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// If we can access window, check to see if we're dealing with app version
|
|
14
|
-
if (typeof window !== "undefined"){
|
|
15
|
-
// Any link with ?fromRichie=1 will have paywall disabled
|
|
16
|
-
// Also hdnEmployeeAccess is the new free param
|
|
17
|
-
// Native in-app webviews will have a custom user agent, so check that too
|
|
18
|
-
if (
|
|
19
|
-
window.location.href.indexOf('fromRichie=1') > -1 ||
|
|
20
|
-
window.location.href.indexOf('hdnEmployeeAccess=true') > -1 ||
|
|
21
|
-
navigator.userAgent.indexOf(' Richie/') > -1) {
|
|
22
|
-
appVersion = true
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return appVersion
|
|
27
|
-
}
|
|
1
|
+
const { appCheck } = require('./appcheck.js')
|
|
28
2
|
|
|
29
3
|
// Blend the HDN var with whatever is already present on the page
|
|
30
4
|
// Returns a string for injection into the head of the page
|