Skip to content

Allow different vendor #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ In gatsby-config.js
options: {
files: ['post/**/index.html', 'index.html'],
publicPath: 'public',
vendor: 'gtag',
gaConfigPath: 'gaConfig.json',
dist: 'public/dist',
optimize: true,
Expand All @@ -39,11 +40,14 @@ In gatsby-config.js
- amp-analytics config json for [google analytics](https://www.ampproject.org/docs/analytics/analytics-vendors)
- The path is from `publicPath`
- Optional
- vendor
- add your vendor, (https://www.ampproject.org/docs/analytics/analytics-vendors)
- defaults to 'googleanalytics'
- dist
- Path to output
- If the options is not set files are override by AMP result
- optimize
- If true, this module will optimize the html by using [@ampproject/toolbox-optimizer](https://github.com/ampproject/amp-toolbox/tree/master/packages/optimizer)
- If true, this module will optimize the html by using [@ampproject/toolbox-optimizer](https://github.com/ampproject/amp-toolbox/tree/master/packages/optimizer)
- htmlPlugins
- you can add custom converter for html
- cssPlugins
Expand Down
4 changes: 3 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ exports.onPostBuild = (_, pluginOptions) => {
files: ['**/*.html'],
publicPath: 'public',
gaConfigPath: null,
vendor: 'googleanalytics',
dist: null,
serviceWorker: null,
optimize: false,
htmlPlugins: [],
cssPlugins: []
}
const { files, publicPath, gaConfigPath, dist, serviceWorker, optimize, htmlPlugins, cssPlugins } = {
const { files, publicPath, gaConfigPath, vendor, dist, serviceWorker, optimize, htmlPlugins, cssPlugins } = {
...defaultOptions,
...pluginOptions
}
Expand All @@ -25,6 +26,7 @@ exports.onPostBuild = (_, pluginOptions) => {
const htmls = globby.sync(absolutePaths)
const config = {
gaConfigPath,
vendor,
cwd: slash(path.join(process.cwd(), publicPath)),
serviceWorker,
optimize,
Expand Down