Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Commit c50d41e

Browse files
author
Sujaykumar Hublikar
committed
add LocalStorage config option
1 parent 89d6d85 commit c50d41e

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ window.$docsify.customPageFooter = {
4040
copyrightOwnerName: '', // copyright owner name
4141
copyrightOwnerLink: undefined, // copyright owner link if any
4242
copyrightExtra: undefined, // any exta text to show below copyright owner section
43+
44+
useLocalStorage: true, // build and store footer in localstorage for quick access
4345
}
4446
```
4547

src/plugin.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const customPageFooterOptions = {
4040
copyrightOwnerName: '', // copyright owner name
4141
copyrightOwnerLink: undefined, // copyright owner link if any
4242
copyrightExtra: undefined, // any exta text to show below copyright owner section
43+
44+
useLocalStorage: true, // build and store footer in localstorage for quick access
4345
}
4446

4547
const _storageKeyFooter = 'custom-footer';
@@ -81,7 +83,8 @@ function buildFooter() {
8183

8284

8385
var footer = '<footer id="customFooter">' + footer + '</footer>';
84-
localStorage.setItem(_storageKeyFooter, footer);
86+
87+
if(customPageFooterOptions.useLocalStorage) localStorage.setItem(_storageKeyFooter, footer);
8588

8689
return footer;
8790
}
@@ -90,8 +93,8 @@ function buildFooter() {
9093
function customPageFooter( hook, vm ) {
9194

9295
// before hook
93-
hook.beforeEach( function( content ) {
94-
});
96+
// hook.beforeEach( function( content ) {
97+
// });
9598

9699
// after hook
97100
hook.doneEach( function() {
@@ -100,10 +103,19 @@ function customPageFooter( hook, vm ) {
100103

101104
if(! _footer){
102105
var node = document.getElementById('main').parentNode;
106+
if(! node){
107+
error('parent node not found!');
108+
return;
109+
}
110+
103111
debug("node"); debug(node);
104112

105-
var footer = localStorage.getItem(_storageKeyFooter);
106-
debug("footer"); debug(footer);
113+
var footer = undefined;
114+
115+
if(customPageFooterOptions.useLocalStorage){
116+
footer = localStorage.getItem(_storageKeyFooter);
117+
debug("footer from ls -> " + footer);
118+
}
107119

108120
node.innerHTML += ((footer) ? footer : buildFooter());
109121
debug("added custom footer!");
@@ -112,11 +124,11 @@ function customPageFooter( hook, vm ) {
112124
}
113125

114126
function debug(msg){
115-
if(customPageFooterOptions.debug) console.log(msg);
127+
if(customPageFooterOptions.debug) console.log('[customPageFooter] log: ' + msg);
116128
}
117129

118130
function error(msg){
119-
if(customPageFooterOptions.debug) console.error(msg);
131+
if(customPageFooterOptions.debug) console.error('[customPageFooter] err: ' + msg);
120132
}
121133

122134

0 commit comments

Comments
 (0)