借助插件“gatsby-plugin-makerwidget”向 Gatsby 添加外部脚本不起作用?
Adding an external script to Gatsby with the help of a plugin `gatsby-plugin-makerwidget` is not working?
昨天我尝试将 https://makerwidget.com 添加到我的网站并在自定义结束时我得到了一个脚本标签,我想将其添加到我的网站
剧本是-
<script>
(function(d, h, m){
var js, fjs = d.getElementsByTagName(h)[0];
if (d.getElementById(m)){return;}
js = d.createElement(h); js.id = m;
js.onload = function(){
window.makerWidgetComInit({
position: "left",
widget: "2hc0aqfnigsyxkf5-aewnonydaddchdgj-vwoc6njlwhycxyw6"
})};
js.src = "https://makerwidget.com/js/embed.js";
fjs.parentNode.insertBefore(js, fjs)
}(document, "script", "dhm"))
</script>
我想将其添加为具有 2 个选项的插件 -
(1) position
即 left
(2) widgetId
即 2hc0aqfnigsyxkf5-aewnonydaddchdgj-vwoc6njlwhycxyw6
我在 https://github.com/deadcoder0904/gatsby-plugin-makerwidget which has no options & its written like gatsby-plugin-twitter 发布了 v1.0.0,但没有用
如何让它添加外部脚本?
以及如何向其中添加 2 个选项 position 和 widgetId?
找到解决方案
我错误地将 gatsby-browser.js
放在 src/
文件夹中,而不是将其放在顶层
其他一切正常:)
昨天我尝试将 https://makerwidget.com 添加到我的网站并在自定义结束时我得到了一个脚本标签,我想将其添加到我的网站
剧本是-
<script>
(function(d, h, m){
var js, fjs = d.getElementsByTagName(h)[0];
if (d.getElementById(m)){return;}
js = d.createElement(h); js.id = m;
js.onload = function(){
window.makerWidgetComInit({
position: "left",
widget: "2hc0aqfnigsyxkf5-aewnonydaddchdgj-vwoc6njlwhycxyw6"
})};
js.src = "https://makerwidget.com/js/embed.js";
fjs.parentNode.insertBefore(js, fjs)
}(document, "script", "dhm"))
</script>
我想将其添加为具有 2 个选项的插件 -
(1) position
即 left
(2) widgetId
即 2hc0aqfnigsyxkf5-aewnonydaddchdgj-vwoc6njlwhycxyw6
我在 https://github.com/deadcoder0904/gatsby-plugin-makerwidget which has no options & its written like gatsby-plugin-twitter 发布了 v1.0.0,但没有用
如何让它添加外部脚本?
以及如何向其中添加 2 个选项 position 和 widgetId?
找到解决方案
我错误地将 gatsby-browser.js
放在 src/
文件夹中,而不是将其放在顶层
其他一切正常:)