Skip to content

Commit

Permalink
feat(add-this): warn at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Sep 19, 2021
1 parent cf2300d commit 131e6c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
11 changes: 4 additions & 7 deletions packages/add-this/src/client/root-components/AddThis.ts
Expand Up @@ -8,14 +8,11 @@ export default defineComponent({

setup() {
onMounted(() => {
if (pubID) {
const link = `//s7.addthis.com/js/300/addthis_widget.js#pubid=${pubID}`;
const script = document.createElement("script");
const link = `//s7.addthis.com/js/300/addthis_widget.js#pubid=${pubID}`;
const script = document.createElement("script");

script.src = link;
document.getElementsByTagName("body")[0].appendChild(script);
} else
console.error("[AddThis]: Please provide a pubid to let plugin work");
script.src = link;
document.getElementsByTagName("body")[0].appendChild(script);
});

return (): VNode => h("div", { class: "add-this" });
Expand Down
32 changes: 21 additions & 11 deletions packages/add-this/src/node/index.ts
Expand Up @@ -5,19 +5,29 @@ import type { AddThisOptions } from "../shared";

export * from "../shared";

const addThisPlugin: Plugin<AddThisOptions> = (options) => ({
name: "add-this",
const addThisPlugin: Plugin<AddThisOptions> = (options) => {
if (!options.pubid) {
console.error("[AddThis]: Please provide a pubid to let plugin work");

define: {
PUB_ID: options.pubid || "",
},
return {
name: "add-this",
};
}

globalUIComponents: "AddThis",
return {
name: "add-this",

clientAppRootComponentFiles: path.resolve(
__dirname,
"../client/root-components/AddThis.js"
),
});
define: {
PUB_ID: options.pubid,
},

globalUIComponents: "AddThis",

clientAppRootComponentFiles: path.resolve(
__dirname,
"../client/root-components/AddThis.js"
),
};
};

export default addThisPlugin;

0 comments on commit 131e6c1

Please sign in to comment.