From d0cb66fa7f38699dfd9c50f47fb4a632516a1529 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Thu, 4 Jun 2020 20:36:22 +0200 Subject: [PATCH] feat(components): :sparkles: show page read progress --- config/config-reader.js | 11 +++++++++-- config/config.yml | 10 ++++++++++ gatsby-config.js | 14 ++++++++++++++ package.json | 1 + yarn.lock | 5 +++++ 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/config/config-reader.js b/config/config-reader.js index ebbedc64..f1a3d691 100644 --- a/config/config-reader.js +++ b/config/config-reader.js @@ -75,7 +75,15 @@ const defaults = { }, scrollTop: true, showMetadata: true, - propagateNetlifyEnv: true + propagateNetlifyEnv: true, + pageProgress: { + enabled: false, + // includePaths: [], + excludePaths: ["/"], + height: 3, + prependToBody: false, + color: '#A05EB5' + } }, }; @@ -214,7 +222,6 @@ const read = () => { config = _.merge(config, envConfig); const netlifyConfig = new NetlifyEnvReader(config.features.propagateNetlifyEnv).read(); config = _.merge(config, netlifyConfig) - console.log("meta", config.metadata) postProcessConfig(config); return config; }; diff --git a/config/config.yml b/config/config.yml index 6985088f..514e7175 100644 --- a/config/config.yml +++ b/config/config.yml @@ -74,3 +74,13 @@ features: scrollTop: true showMetadata: true propagateNetlifyEnv: true + pageProgress: + enabled: true + includePaths: + - "/configuration/advanced/theme" + - regex: "^/syntax" + excludePaths: + - "/" + height: 3 + prependToBody: false + color: '#A05EB5' diff --git a/gatsby-config.js b/gatsby-config.js index ff3bdebc..46b399ae 100755 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -98,6 +98,20 @@ const plugins = [ }, }, ]; + +if (config.features.pageProgress && config.features.pageProgress.enabled) { + plugins.push( + { + resolve: "gatsby-plugin-page-progress", + options: { + includePaths: config.features.pageProgress.includePaths, + excludePaths: config.features.pageProgress.excludePaths, + height: config.features.pageProgress.height, + prependToBody: config.features.pageProgress.prependToBody, + color: config.features.pageProgress.color + } + }); +} // check and add algolia if ( config.features.search && diff --git a/package.json b/package.json index 90d68eab..d5e2e6fa 100755 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "gatsby-plugin-manifest": "2.4.9", "gatsby-plugin-mdx": "1.2.13", "gatsby-plugin-offline": "3.2.7", + "gatsby-plugin-page-progress": "2.0.16", "gatsby-plugin-react-helmet": "3.3.2", "gatsby-plugin-react-svg": "3.0.0", "gatsby-plugin-remove-serviceworker": "1.0.0", diff --git a/yarn.lock b/yarn.lock index 168e4387..0b041d6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7252,6 +7252,11 @@ gatsby-plugin-page-creator@^2.3.7: lodash "^4.17.15" micromatch "^3.1.10" +gatsby-plugin-page-progress@2.0.16: + version "2.0.16" + resolved "https://registry.yarnpkg.com/gatsby-plugin-page-progress/-/gatsby-plugin-page-progress-2.0.16.tgz#cb1b392490d5ee0be4cbe3dce1db2d24c888e430" + integrity sha512-1dDUbsvjNCWdh5pammrJaCkCeE4Tk2YLxeh7N7WWHbsJ+BDqpuCxaXb/dw+ph2uVY595kJQXZTxP5hGAsK8SqA== + gatsby-plugin-react-helmet@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/gatsby-plugin-react-helmet/-/gatsby-plugin-react-helmet-3.3.2.tgz#5619a1808d9607eb89c19d3f04854f497c6fb890"