diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7dd612f..3366014 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,6 +5,8 @@ + + + + + + + @@ -77,7 +91,7 @@ diff --git a/docs/docsify-plugin-ads.js b/docs/docsify-plugin-ads.js new file mode 100644 index 0000000..2f9e9a5 --- /dev/null +++ b/docs/docsify-plugin-ads.js @@ -0,0 +1,105 @@ +(function(window) { + window.DocsifyAds = { + create(caPub) { + return function(hook, vm) { + hook.ready(function() { + window.DocsifyAds.injectCarbonStyle(); + }); + + hook.doneEach(function() { + window.DocsifyAds.injectScript(caPub); + }); + }; + }, + + injectScript(caPub) { + const adEl = document.querySelector("#adsense"); + const scriptID = "_adsense_js"; + const sidebarEl = document.querySelector(".sidebar-nav"); + + if (!adEl && sidebarEl) { + let scriptEl = document.querySelector(`#${scriptID}`); + + if (scriptEl) { + scriptEl = scriptEl.parentNode.removeChild(scriptEl); + } else { + scriptEl = document.createElement("script"); + scriptEl.src = `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${caPub}`; + scriptEl.async = "async"; + scriptEl.id = scriptID; + } + + sidebarEl.insertBefore(scriptEl, sidebarEl.firstChild); + } + }, + + injectCarbonStyle() { + const styleEl = document.createElement("style"); + + styleEl.textContent = ` + #carbonads * { + margin: initial; + padding: initial; + } + + #carbonads { + max-width: 330px; + background-color: #fafafa; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, + Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, + sans-serif; + } + + #carbonads a { + color: inherit; + text-decoration: none; + } + + #carbonads a:hover { + color: inherit; + } + + #carbonads span { + display: block; + position: relative; + overflow: hidden; + } + + #carbonads .carbon-wrap { + display: flex; + } + + #carbonads .carbon-img img { + display: block; + } + + #carbonads .carbon-text { + align-self: center; + margin-bottom: 20px; + padding: 8px 10px; + font-size: 12px; + line-height: 1.5; + text-align: left; + } + + #carbonads .carbon-poweredby { + display: block; + position: absolute; + bottom: 0; + right: 0; + padding: 6px 8px; + border-top-left-radius: 3px; + background-color: #f1f1f1; + font-size: 8px; + font-weight: 600; + line-height: 1; + letter-spacing: 0.5px; + text-align: center; + text-transform: uppercase; + } + `; + + document.head.insertBefore(styleEl, document.querySelector("head style, head link[rel*='stylesheet']")); + }, + }; +})(window); \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 4f19d09..0e3447b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,9 +43,10 @@ +
Loading ...
- +