feat: add wwads plugin.

This commit is contained in:
Ryan Wang
2021-10-12 19:05:00 +08:00
parent 6148feb120
commit 03016cadbc
3 changed files with 48 additions and 4 deletions

View File

@@ -232,6 +232,7 @@ const darkCodeTheme = require("prism-react-renderer/themes/palenight");
],
},
],
"./src/plugins/plugin-wwads/index.js",
],
scripts: [
{
@@ -240,10 +241,6 @@ const darkCodeTheme = require("prism-react-renderer/themes/palenight");
defer: true,
"data-website-id": "7e8d48ad-973d-4b44-b36d-ea1f1df25baa",
},
{
src: "https://cdn.wwads.cn/js/makemoney.js",
async: true,
},
{
src: "/js/wwads.js",
},

View File

@@ -0,0 +1,27 @@
const path = require("path");
function pluginWwads() {
return {
name: "docusaurus-plugin-wwads",
getClientModules() {
return [path.resolve(__dirname, "./wwads")];
},
injectHtmlTags() {
return {
headTags: [
{
tagName: "script",
attributes: {
async: true,
src: `https://cdn.wwads.cn/js/makemoney.js`,
},
},
],
};
},
};
}
exports.default = pluginWwads;

View File

@@ -0,0 +1,20 @@
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
export default (function () {
if (!ExecutionEnvironment.canUseDOM) {
return null;
}
return {
onRouteUpdate() {
setTimeout(() => {
const ad = document.getElementsByClassName("table-of-contents");
const adnode = document.createElement("div");
adnode.setAttribute("class", "wwads-cn wwads-vertical");
adnode.setAttribute("data-id", "80");
adnode.setAttribute("style", "max-width:200px");
ad[0].parentNode.appendChild(adnode);
}, 2000);
},
};
})();