UNPKG

gatsby-plugin-web-monetization

Version:

A simple GatsbyJS plugin that implements Web Monetization Meta Tag

46 lines (37 loc) 1.26 kB
"use strict"; exports.__esModule = true; exports.onPreRenderHTML = void 0; var React = require("react"); var onPreRenderHTML = function onPreRenderHTML(_ref, pluginOptions) { var reporter = _ref.reporter, getHeadComponents = _ref.getHeadComponents, replaceHeadComponents = _ref.replaceHeadComponents, pathname = _ref.pathname; if (process.env.NODE_ENV !== "production") { // reporter.warn("non production environment"); return null; } if (!pluginOptions.paymentPointer) { // reporter.warn( // `Payment Pointer is not defined, add it to your gatsby-config.js file.` // ); return null; } if (pluginOptions.excludedPaths && pluginOptions.excludedPaths.length > 0) { var excludedPaths = pluginOptions.excludedPaths; var isExcluded = excludedPaths.filter(function (path) { return pathname.match(path); }).length > 0; if (isExcluded) { return null; } } var headComponents = getHeadComponents(); var webMonetizationTag = /*#__PURE__*/React.createElement("meta", { name: "monetization", content: pluginOptions.paymentPointer }); headComponents.push(webMonetizationTag); replaceHeadComponents(headComponents); }; exports.onPreRenderHTML = onPreRenderHTML;