Skip to content

Commit

Permalink
refactor: config usage from component
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Aug 7, 2021
1 parent adfb04f commit f440f9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/PlausibleProvider.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import { Helmet } from '@plone/volto/helpers';
import config from '@plone/volto/registry';

const PlausibleProvider = ({ domain }) =>
domain ? (
const PlausibleProvider = () => {
const domain = config.settings.plausibleDomain;

return domain ? (
<React.Fragment>
<Helmet>
<script
Expand All @@ -13,5 +16,6 @@ const PlausibleProvider = ({ domain }) =>
</Helmet>
</React.Fragment>
) : null;
};

export default PlausibleProvider;
13 changes: 4 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import PlausibleProvider from './PlausibleProvider';

export default function applyConfig(config) {
if (config.settings.plausibleDomain) {
config.settings.appExtras.push({
match: '',
component: PlausibleProvider,
props: {
domain: config.settings.plausibleDomain,
},
});
}
config.settings.appExtras.push({
match: '',
component: PlausibleProvider,
});

return config;
}

0 comments on commit f440f9e

Please sign in to comment.