UNPKG

@sujaykumarh/docsify-plugin-footer

Version:
26 lines 2.87 kB
/** * @license * * docsify-plugin-footer/plugin.js v1.2.0 * (https://github.com/Sujaykumarh/docsify-plugin-footer/) * * Copyright (c) 2021 Sujaykumar.Hublikar <hello@sujaykumarh.com> * Github (@sujaykumarh) * * Licensed under Apache License, Version 2.0 */ /** * @preserve * * generates footer * * | content here * | .... * sidebar | .... * | * | ___________________________________________________________________ * | * | copyright (c) 2021 copyrightOwner. Powered by docsify. * | [---copyrightExtra---] */ "use strict";const customPageFooterOptions={debug:false,showPoweredBy:true,copyrightYear:"",showCopyright:true,copyright:undefined,copyrightOwnerName:"",copyrightOwnerLink:undefined,copyrightExtra:undefined,useLocalStorage:true};const _storageKeyFooter="custom-footer";function buildFooter(){var footer="";if(customPageFooterOptions.showPoweredBy){footer+='<span class="powered-by">Powered by <a href="https://github.com/docsifyjs/docsify" target="_blank">docsify</a>.</span>'}if(customPageFooterOptions.showCopyright&&!customPageFooterOptions.copyright){footer+='<span class="copyright">&copy; ';footer+=customPageFooterOptions.copyrightYear?customPageFooterOptions.copyrightYear:(new Date).getFullYear();if(!customPageFooterOptions.copyrightOwnerLink){footer+=customPageFooterOptions.copyrightOwnerName+"."}else{footer+='<a href="'+customPageFooterOptions.copyrightOwnerLink+'" target="_blank">'+customPageFooterOptions.copyrightOwnerName+"</a>."}if(customPageFooterOptions.copyrightExtra){footer+='<div class="copyright-extra">';footer+=customPageFooterOptions.copyrightExtra;footer+="</div>"}footer+="</span>"}else{footer+=customPageFooterOptions.copyright}var footer='<footer id="customFooter">'+footer+"</footer>";if(customPageFooterOptions.useLocalStorage)localStorage.setItem(_storageKeyFooter,footer);return footer}function customPageFooter(hook,vm){hook.doneEach((function(){var _footer=document.getElementById("customFooter");debug("_footer");debug(_footer);if(!_footer){var node=document.getElementById("main").parentNode;if(!node){error("parent node not found!");return}debug("node");debug(node);var footer=undefined;if(customPageFooterOptions.useLocalStorage){footer=localStorage.getItem(_storageKeyFooter);debug("footer from ls -> "+footer)}node.innerHTML+=footer?footer:buildFooter();debug("added custom footer!")}}))}function debug(msg){if(customPageFooterOptions.debug)console.log("[customPageFooter] log: "+msg)}function error(msg){if(customPageFooterOptions.debug)console.error("[customPageFooter] err: "+msg)}window.$docsify.customPageFooter=Object.assign(customPageFooterOptions,window.$docsify.customPageFooter);window.$docsify.plugins=[].concat(customPageFooter,window.$docsify.plugins);