Skip to content

Commit 0d3e207

Browse files
authored
Merge pull request #26 from eyalroth/dev
2 parents 0115951 + c760089 commit 0d3e207

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+594
-1156
lines changed

gatsby-browser.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ require("prismjs/plugins/line-numbers/prism-line-numbers.css")
33

44
import littlefoot from 'littlefoot'
55
import 'littlefoot/dist/littlefoot.css'
6+
import './src/assets/scss/_progress.scss'
67

78
export const onServiceWorkerUpdateReady = () => {
89
const answer = window.confirm(

gatsby-config.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,9 @@ module.exports = {
3434
],
3535
author: {
3636
name: 'John Doe',
37-
email: '#',
38-
telegram: '#',
39-
twitter: '#',
37+
linkedin: "#",
4038
github: '#',
41-
rss: '#',
42-
vk: '#',
39+
email: '#',
4340
},
4441
},
4542
plugins: [
@@ -73,6 +70,7 @@ module.exports = {
7370
},
7471
'gatsby-remark-copy-linked-files',
7572
'gatsby-remark-smartypants',
73+
`gatsby-remark-reading-time`,
7674
],
7775
},
7876
},
@@ -141,6 +139,12 @@ module.exports = {
141139
},
142140
`gatsby-plugin-offline`,
143141
`gatsby-plugin-netlify`,
144-
`gatsby-plugin-robots-txt`
142+
`gatsby-plugin-robots-txt`,
143+
{
144+
resolve: 'gatsby-plugin-page-progress-fork',
145+
options: {
146+
includePaths: ['/', { regex: '^/blog' }],
147+
}
148+
},
145149
],
146150
}

package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"gatsby-remark-copy-linked-files": "^2.0.5",
4242
"gatsby-remark-images": "^2.0.4",
4343
"gatsby-remark-prismjs": "^3.2.11",
44+
"gatsby-remark-reading-time": "^1.0.1",
4445
"gatsby-remark-responsive-iframe": "^2.0.5",
4546
"gatsby-remark-smartypants": "^2.0.5",
4647
"gatsby-source-filesystem": "^2.0.3",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import './progress.css'
2+
3+
const defaultOptions = {
4+
includePaths: [],
5+
excludePaths: [],
6+
height: null,
7+
prependToBody: false,
8+
color: null,
9+
}
10+
11+
// browser API usage: https://www.gatsbyjs.org/docs/browser-apis/#onRouteUpdate
12+
export const onRouteUpdate = (
13+
{ location: { pathname } },
14+
pluginOptions = {}
15+
) => {
16+
// merge default options with user defined options in `gatsby-config.js`
17+
const options = { ...defaultOptions, ...pluginOptions }
18+
19+
const { includePaths, excludePaths, height, prependToBody, color } = options
20+
21+
function pageProgress() {
22+
// create progress indicator container and append/prepend to document body
23+
const node = document.createElement(`div`)
24+
node.id = `gatsby-plugin-page-progress`
25+
// eslint-disable-next-line
26+
prependToBody ? document.body.prepend(node) : document.body.append(node)
27+
28+
// set defaults and grab progress indicator from the DOM
29+
let scrolling = false
30+
const indicator = document.getElementById(`gatsby-plugin-page-progress`)
31+
32+
if (height != null) {
33+
indicator.style.height = `${height}px`
34+
}
35+
36+
if (color != null) {
37+
indicator.style.backgroundColor = color
38+
}
39+
40+
// determine width of progress indicator
41+
const getIndicatorPercentageWidth = (currentPos, totalScroll) => {
42+
return currentPos / totalScroll * 100
43+
}
44+
45+
// find the total height of window
46+
const getScrollHeight = () => {
47+
// https://javascript.info/size-and-scroll-window#width-height-of-the-document
48+
return Math.max(
49+
document.body.scrollHeight,
50+
document.documentElement.scrollHeight,
51+
document.body.offsetHeight,
52+
document.documentElement.offsetHeight,
53+
document.body.clientHeight,
54+
document.documentElement.clientHeight
55+
)
56+
}
57+
58+
// add throttled listener to update on scroll
59+
window.addEventListener(`scroll`, () => {
60+
const currentPos = window.scrollY
61+
const { innerHeight } = window
62+
const scrollHeight = getScrollHeight()
63+
const scrollDistance = scrollHeight - innerHeight
64+
65+
if (!scrolling) {
66+
window.requestAnimationFrame(() => {
67+
const indicatorWidth = getIndicatorPercentageWidth(
68+
currentPos,
69+
scrollDistance
70+
)
71+
indicator.style.width = indicatorWidth + '%'
72+
scrolling = false
73+
})
74+
scrolling = true
75+
}
76+
})
77+
}
78+
79+
function checkPaths(val, paths) {
80+
if (paths.length === 0) return val // return if no paths
81+
let returnVal = val
82+
83+
// loop over each path
84+
paths.forEach(x => {
85+
// if returnVal has already changed => return
86+
if (returnVal === !val) return
87+
// regex is supplied in an object: { regex: '/beep/beep/lettuce' }
88+
const isRegex = typeof x === `object`
89+
90+
// if regex is present test it against the pathname - if test passes, change returnVal
91+
if (isRegex && new RegExp(x.regex, `gm`).test(pathname))
92+
returnVal = !returnVal
93+
// otherwise if the current path is strictly equal to the pathname, change returnVal
94+
if (x === pathname) returnVal = !returnVal
95+
})
96+
97+
return returnVal
98+
}
99+
100+
// check to see if the scroll indicator already exists - if it does, remove it
101+
function removeProgressIndicator() {
102+
const indicatorCheck = document.getElementById(
103+
`gatsby-plugin-page-progress`
104+
)
105+
if (indicatorCheck) indicatorCheck.remove()
106+
}
107+
108+
// if there's no excluded paths && no included paths
109+
if (!excludePaths.length && !includePaths.length) {
110+
removeProgressIndicator()
111+
pageProgress()
112+
// if there's excluded paths && no included paths
113+
} else if (excludePaths.length && !includePaths.length) {
114+
const continueAfterExclude = checkPaths(true, excludePaths)
115+
removeProgressIndicator()
116+
117+
if (continueAfterExclude) pageProgress()
118+
// if there's either excluded paths && included paths || no excluded paths && included paths
119+
} else {
120+
const continueAfterExclude = checkPaths(true, excludePaths)
121+
removeProgressIndicator()
122+
123+
if (continueAfterExclude) {
124+
const match = checkPaths(false, includePaths)
125+
match && pageProgress()
126+
}
127+
}
128+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "gatsby-plugin-page-progress-fork",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#gatsby-plugin-page-progress {
2+
position: fixed;
3+
top: 0;
4+
left: 0;
5+
transition: width 0.25s;
6+
height: 3px;
7+
background-color: #663399;
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"name": "",
3+
"css_prefix_text": "icon-",
4+
"css_use_suffix": false,
5+
"hinting": true,
6+
"units_per_em": 1000,
7+
"ascent": 850,
8+
"glyphs": [
9+
{
10+
"uid": "0f6a2573a7b6df911ed199bb63717e27",
11+
"css": "github-circled",
12+
"code": 61595,
13+
"src": "fontawesome"
14+
},
15+
{
16+
"uid": "1145676a91138011729fa2909997af66",
17+
"css": "linkedin-squared",
18+
"code": 62220,
19+
"src": "fontawesome"
20+
},
21+
{
22+
"uid": "e9107949dd6c9e8ab2b29ae07156e38c",
23+
"css": "linkedin",
24+
"code": 61665,
25+
"src": "fontawesome"
26+
},
27+
{
28+
"uid": "4743b088aa95d6f3b6b990e770d3b647",
29+
"css": "facebook-squared",
30+
"code": 62216,
31+
"src": "fontawesome"
32+
},
33+
{
34+
"uid": "6cc7af3e5b55720bcb6ef68372ce24be",
35+
"css": "facebook-official",
36+
"code": 62000,
37+
"src": "fontawesome"
38+
},
39+
{
40+
"uid": "bf882b30900da12fca090d9796bc3030",
41+
"css": "mail",
42+
"code": 59392,
43+
"src": "fontawesome"
44+
},
45+
{
46+
"uid": "ccc2329632396dc096bb638d4b46fb98",
47+
"css": "mail-alt",
48+
"code": 61664,
49+
"src": "fontawesome"
50+
},
51+
{
52+
"uid": "bf09b1c6561dc0ced707476e2cd83d29",
53+
"css": "medium",
54+
"code": 62010,
55+
"src": "fontawesome"
56+
},
57+
{
58+
"uid": "4c1ef492f1d2c39a2250ae457cee2a6e",
59+
"css": "instagram",
60+
"code": 61805,
61+
"src": "fontawesome"
62+
},
63+
{
64+
"uid": "9d3e9faf68fd4e12def853f0d4e1173b",
65+
"css": "whatsapp",
66+
"code": 62002,
67+
"src": "fontawesome"
68+
},
69+
{
70+
"uid": "627abcdb627cb1789e009c08e2678ef9",
71+
"css": "twitter",
72+
"code": 61593,
73+
"src": "fontawesome"
74+
},
75+
{
76+
"uid": "72b1277834cba5b7944b0a6cac7ddb0d",
77+
"css": "rss",
78+
"code": 61598,
79+
"src": "fontawesome"
80+
},
81+
{
82+
"uid": "de5f0a564ccf8816325330e292e11533",
83+
"css": "rss-squared",
84+
"code": 61763,
85+
"src": "fontawesome"
86+
},
87+
{
88+
"uid": "e1597911f34fea0a188ae51fe4a2d9a9",
89+
"css": "stackoverflow",
90+
"code": 61804,
91+
"src": "fontawesome"
92+
}
93+
]
94+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
.icon-mail:before { content: '\e800'; } /* '' */
3+
.icon-twitter:before { content: '\f099'; } /* '' */
4+
.icon-github-circled:before { content: '\f09b'; } /* '' */
5+
.icon-rss:before { content: '\f09e'; } /* '' */
6+
.icon-mail-alt:before { content: '\f0e0'; } /* '' */
7+
.icon-linkedin:before { content: '\f0e1'; } /* '' */
8+
.icon-rss-squared:before { content: '\f143'; } /* '' */
9+
.icon-stackoverflow:before { content: '\f16c'; } /* '' */
10+
.icon-instagram:before { content: '\f16d'; } /* '' */
11+
.icon-facebook-official:before { content: '\f230'; } /* '' */
12+
.icon-whatsapp:before { content: '\f232'; } /* '' */
13+
.icon-medium:before { content: '\f23a'; } /* '' */
14+
.icon-facebook-squared:before { content: '\f308'; } /* '' */
15+
.icon-linkedin-squared:before { content: '\f30c'; } /* '' */

src/assets/fonts/fontello-1c73886c/css/fontello-embedded.css

+68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
.icon-mail { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
3+
.icon-twitter { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
4+
.icon-github-circled { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
5+
.icon-rss { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
6+
.icon-mail-alt { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
7+
.icon-linkedin { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
8+
.icon-rss-squared { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
9+
.icon-stackoverflow { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
10+
.icon-instagram { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
11+
.icon-facebook-official { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
12+
.icon-whatsapp { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
13+
.icon-medium { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
14+
.icon-facebook-squared { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
15+
.icon-linkedin-squared { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }

src/assets/fonts/fontello-771c82e0/css/fontello-ie7.css src/assets/fonts/fontello-1c73886c/css/fontello-ie7.css

+7-9
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212

1313
.icon-mail { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
1414
.icon-twitter { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
15-
.icon-facebook { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
15+
.icon-github-circled { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
1616
.icon-rss { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
17+
.icon-mail-alt { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
1718
.icon-linkedin { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
18-
.icon-github { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
19+
.icon-rss-squared { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
1920
.icon-stackoverflow { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
2021
.icon-instagram { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
21-
.icon-tumblr { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
22-
.icon-dribbble { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
23-
.icon-skype { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
24-
.icon-vkontakte { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
25-
.icon-slack { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
26-
.icon-paper-plane { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
22+
.icon-facebook-official { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
2723
.icon-whatsapp { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
28-
.icon-odnoklassniki { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
24+
.icon-medium { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
25+
.icon-facebook-squared { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
26+
.icon-linkedin-squared { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }

0 commit comments

Comments
 (0)