@markbattistella/docsify-sidebarfooter 4.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -59
- package/dist/docsify-sidebar.js +220 -0
- package/dist/docsify-sidebar.min.js +2 -0
- package/package.json +16 -9
- package/dist/docsify-sidebarFooter.js +0 -281
- package/dist/docsify-sidebarFooter.min.js +0 -7
package/README.md
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# docsify.js sidebar footer
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
   
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
[](https://www.paypal.me/markbattistella/6AUD)
|
|
10
|
-
[](https://www.buymeacoffee.com/markbattistella)
|
|
11
|
-
|
|
12
|
-
[](https://markbattistella.github.io/docsify-sidebarfooter/)
|
|
13
|
-
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
This plugin is designed to create a footer area at the base of your sidebar (or page) where you can list a copyright year (range), your name or company with a URL, and links to a privacy policy, terms of service, and a cookies policy.
|
|
19
|
-
|
|
20
|
-
---
|
|
3
|
+
This plugin enhances your website's sidebar or page by creating a footer area where you can display important information. It automatically updates the copyright year or range, allows you to include your name or company with a URL, and provides links to a privacy policy, terms of service, and cookies policy pages. By utilising this plugin, you can easily showcase relevant legal information, personalise your website, and promote transparency and compliance.
|
|
21
4
|
|
|
22
5
|
## Installation
|
|
23
6
|
|
|
@@ -25,7 +8,7 @@ This plugin is designed to create a footer area at the base of your sidebar (or
|
|
|
25
8
|
|
|
26
9
|
Assuming you have a working [docsify](https://docsify.js.org/) framework set up, it is easy to use the plugin.
|
|
27
10
|
|
|
28
|
-
1. Add the following script
|
|
11
|
+
1. Add one of the following script tags to your `index.html` via either CDN or downloading it and using it locally:
|
|
29
12
|
|
|
30
13
|
```html
|
|
31
14
|
<!-- unpkg.com -->
|
|
@@ -35,7 +18,7 @@ Assuming you have a working [docsify](https://docsify.js.org/) framework set up,
|
|
|
35
18
|
<script src="https://cdn.jsdelivr.net/npm/@markbattistella/docsify-sidebarfooter@latest"></script>
|
|
36
19
|
|
|
37
20
|
<!-- locally -->
|
|
38
|
-
<script src="docsify-
|
|
21
|
+
<script src="docsify-sidebar.min.js"></script>
|
|
39
22
|
```
|
|
40
23
|
|
|
41
24
|
1. In docsify setup configure the plugin:
|
|
@@ -44,76 +27,153 @@ Assuming you have a working [docsify](https://docsify.js.org/) framework set up,
|
|
|
44
27
|
<script>
|
|
45
28
|
window.$docsify = {
|
|
46
29
|
autoFooter: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
30
|
+
|
|
31
|
+
// the name you wish to display as the copyright holder
|
|
32
|
+
name: String,
|
|
33
|
+
|
|
34
|
+
// the URL (personal or company) which clicking the `name` goes to
|
|
35
|
+
url: String,
|
|
36
|
+
|
|
37
|
+
// the start year of copyright
|
|
38
|
+
copyYear: String,
|
|
39
|
+
|
|
40
|
+
// show the privacy policy link
|
|
41
|
+
policy: Bool | String,
|
|
42
|
+
|
|
43
|
+
// show the terms of service link
|
|
44
|
+
terms: Bool | String,
|
|
45
|
+
|
|
46
|
+
// show the cookies policy link
|
|
47
|
+
cookies: Bool | String,
|
|
48
|
+
|
|
49
|
+
// use your own css styles or the built in ones
|
|
50
|
+
customStyle: Bool | String
|
|
54
51
|
}
|
|
55
52
|
};
|
|
56
53
|
</script>
|
|
57
54
|
```
|
|
58
55
|
|
|
59
|
-
###
|
|
56
|
+
### Additional files
|
|
57
|
+
|
|
58
|
+
#### Default
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
If you set the `policy`, `terms`, or `cookies` options to `true` the URL links for those pages will look for the markdown files directly next to the `index.html` file:
|
|
62
61
|
|
|
63
|
-
```
|
|
64
|
-
|
|
62
|
+
```js
|
|
63
|
+
// ... other config
|
|
64
|
+
policy: true,
|
|
65
|
+
terms: true,
|
|
66
|
+
cookies: true,
|
|
67
|
+
// ... other config
|
|
65
68
|
```
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
```md
|
|
71
|
+
- index.html --> https://your-awesome-site.com/#/
|
|
72
|
+
- _policy.md --> https://your-awesome-site.com/#/_policy
|
|
73
|
+
- _terms.md --> https://your-awesome-site.com/#/_terms
|
|
74
|
+
- _cookies.md --> https://your-awesome-site.com/#/_cookies
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### Sub-folder
|
|
68
78
|
|
|
69
|
-
|
|
79
|
+
However, if you enter a string it will append that to the base URL of your website:
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
// ... other config
|
|
83
|
+
policy: 'site/policy',
|
|
84
|
+
terms: 'site/terms',
|
|
85
|
+
cookies: 'site/cookies',
|
|
86
|
+
// ... other config
|
|
87
|
+
```
|
|
70
88
|
|
|
71
89
|
```md
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
- index.html --> https://your-awesome-site.com/#/
|
|
91
|
+
- site/
|
|
92
|
+
\__ policy.md --> https://your-awesome-site.com/#/site/policy
|
|
93
|
+
\__ terms.md --> https://your-awesome-site.com/#/site/terms
|
|
94
|
+
\__ cookies.md --> https://your-awesome-site.com/#/site/cookies
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### External links
|
|
98
|
+
|
|
99
|
+
If you host your policy, terms, or cookies messages on an external website (or need to link to a parent company policy) you can add them in as the full URL:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
// ... other config
|
|
103
|
+
policy: "https://my-other-website.com/policy",
|
|
104
|
+
terms: "https://my-other-website.com/terms",
|
|
105
|
+
cookies: "https://my-other-website.com/cookies",
|
|
106
|
+
// ... other config
|
|
77
107
|
```
|
|
78
108
|
|
|
109
|
+
These will open those pages in a new tab directly.
|
|
110
|
+
|
|
79
111
|
## Configuration
|
|
80
112
|
|
|
81
113
|
There are some options available for the `docsify-sidebarfooter`:
|
|
82
114
|
|
|
83
|
-
|
|
|
84
|
-
|
|
85
|
-
| `name`
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `policy`
|
|
89
|
-
| `terms`
|
|
90
|
-
| `cookies`
|
|
91
|
-
| `
|
|
115
|
+
| Setting | Type | Options |
|
|
116
|
+
|---------------|----------------|------------------------------------|
|
|
117
|
+
| `name` | String | your name or company |
|
|
118
|
+
| `url` | String | url you want the `name` to link to |
|
|
119
|
+
| `copyYear` | String | first year of copyright |
|
|
120
|
+
| `policy` | Bool or String | - `false` hides it from the site<br/>- `true` defaults to `_policy.md`<br/>- a custom string will direct to that |
|
|
121
|
+
| `terms` | Bool or String | - `false` hides it from the site<br/>- `true` defaults to `_terms.md`<br/>- a custom string will direct to that |
|
|
122
|
+
| `cookies` | Bool or String | - `false` hides it from the site<br/>- `true` defaults to `_cookies.md`<br/>- a custom string will direct to that |
|
|
123
|
+
| `customStyle` | Bool or String | - `false` uses in-built css (sidebar styled)<br/>- `true` applies no styles, you can create your own<br/>- `sidebar` uses the in-built css designed for the sidebar<br/>- `body` uses the in-built css designed for the body |
|
|
92
124
|
|
|
93
125
|
## Usage
|
|
94
126
|
|
|
127
|
+
### Sidebar
|
|
128
|
+
|
|
95
129
|
At the bottom of your `_sidebar.md` file add the following code:
|
|
96
130
|
|
|
97
131
|
```html
|
|
98
132
|
<footer id="mb-footer"></footer>
|
|
99
133
|
```
|
|
100
134
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
1. Clone the repo:
|
|
104
|
-
|
|
105
|
-
`git clone https://github.com/markbattistella/docsify-sidebarFooter.git`
|
|
135
|
+
### Body
|
|
106
136
|
|
|
107
|
-
|
|
137
|
+
Under the `<div id="app"></div>` in your `index.html` file, add the following code:
|
|
108
138
|
|
|
109
|
-
|
|
139
|
+
```html
|
|
140
|
+
<footer id="mb-footer"></footer>
|
|
141
|
+
```
|
|
110
142
|
|
|
111
|
-
|
|
143
|
+
## Styling
|
|
112
144
|
|
|
113
|
-
|
|
145
|
+
The links container is sectioned into different classes for you to customise as much (or little) as you wish.
|
|
114
146
|
|
|
115
|
-
|
|
147
|
+
```html
|
|
148
|
+
<footer id="mb-footer">
|
|
149
|
+
<div class="footer-container">
|
|
150
|
+
<div class="footer-text">
|
|
151
|
+
<span class="footer-text-copyright">
|
|
152
|
+
Copyright © YYYY-YYYY
|
|
153
|
+
</span>
|
|
154
|
+
<span class="footer-text-author">
|
|
155
|
+
<a target="_blank" href="">Your website name</a>
|
|
156
|
+
</span>
|
|
157
|
+
</div>
|
|
158
|
+
<div class="footer-link">
|
|
159
|
+
<span class="footer-links-policy">
|
|
160
|
+
<a href="">Policy</a>
|
|
161
|
+
</span>
|
|
162
|
+
<span class="footer-links-terms">
|
|
163
|
+
<a href="">Terms</a>
|
|
164
|
+
</span>
|
|
165
|
+
<span class="footer-links-cookies">
|
|
166
|
+
<a href="">Cookies</a>
|
|
167
|
+
</span>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</footer>
|
|
171
|
+
```
|
|
116
172
|
|
|
117
|
-
|
|
173
|
+
## Contributing
|
|
118
174
|
|
|
175
|
+
1. Clone the repo:<br>`git clone https://github.com/markbattistella/docsify-sidebarFooter.git`
|
|
176
|
+
2. Create your feature branch:<br>`git checkout -b my-feature`
|
|
177
|
+
3. Commit your changes:<br>`git commit -am 'Add some feature'`
|
|
178
|
+
4. `Push` to the branch:<br>`git push origin my-new-feature`
|
|
119
179
|
5. Submit the `pull` request
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/*! docsify-sidebarFooter.js v5.0.1 | (c) Mark Battistella */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// MARK: - check if object exists and is not empty
|
|
5
|
+
function doesObjectExists(obj) {
|
|
6
|
+
return (
|
|
7
|
+
obj !== undefined &&
|
|
8
|
+
obj !== null &&
|
|
9
|
+
obj.constructor === Object &&
|
|
10
|
+
Object.keys(obj).length > 0
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// MARK: - update the `options` object
|
|
16
|
+
function getFooter(options) {
|
|
17
|
+
|
|
18
|
+
// -- get this year
|
|
19
|
+
let date = new Date().getFullYear();
|
|
20
|
+
|
|
21
|
+
// -- update the variables
|
|
22
|
+
options.name ? options.name : null;
|
|
23
|
+
options.url ? options.url : null;
|
|
24
|
+
options.copyYear ? options.copyYear : date;
|
|
25
|
+
options.policy ? options.policy : false;
|
|
26
|
+
options.terms ? options.terms : false;
|
|
27
|
+
options.cookies ? options.cookies : false;
|
|
28
|
+
options.customStyle ? options.customStyle : false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// defaults - and setup
|
|
33
|
+
const options = {
|
|
34
|
+
name: '',
|
|
35
|
+
url: '',
|
|
36
|
+
copyYear: '',
|
|
37
|
+
policy: true,
|
|
38
|
+
terms: true,
|
|
39
|
+
cookies: true,
|
|
40
|
+
customStyle: false
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// -- run the function
|
|
45
|
+
function autoFooter(hook, vm) {
|
|
46
|
+
|
|
47
|
+
// MARK: run with docsify init
|
|
48
|
+
hook.init(function () {
|
|
49
|
+
|
|
50
|
+
// -- initialise the options
|
|
51
|
+
getFooter(options);
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// -- check the options for bool or string
|
|
55
|
+
if (typeof options.customStyle === "boolean" || typeof options.customStyle === "string") {
|
|
56
|
+
|
|
57
|
+
// -- dont continue if using custom styles
|
|
58
|
+
if ((typeof options.customStyle === "boolean" && options.customStyle === true)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// -- global style
|
|
63
|
+
let style = `#mb-footer { border-top: 1px solid; font-size: 0.8em; line-height: 1.5; transition: all var(--sidebar-transition-duration) ease-out; }`;
|
|
64
|
+
|
|
65
|
+
// -- custom style for sidebar
|
|
66
|
+
if ((typeof options.customStyle === "boolean" && options.customStyle === false) ||
|
|
67
|
+
(options.customStyle === "sidebar")
|
|
68
|
+
) {
|
|
69
|
+
style += `#mb-footer { padding-top: 1.5rem; margin-top: 1.5rem; } #mb-footer .footer-text, #mb-footer .footer-text a { font-weight: bold; }`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// -- custom style for sidebar
|
|
73
|
+
if (options.customStyle === "body") {
|
|
74
|
+
|
|
75
|
+
// --> if there is a sidebar
|
|
76
|
+
if( $docsify.loadSidebar || $docsify.loadSidebar === null || !$docsify.hideSidebar ) {
|
|
77
|
+
style += `body #mb-footer { margin-left: var(--sidebar-width); } body.close #mb-footer { margin-left: 0; }`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// --> standard
|
|
81
|
+
style += `#mb-footer { padding: 1.5rem; } #mb-footer .footer-container { max-width: var(--content-max-width); margin: 0 auto; } #mb-footer .footer-container { display: grid; grid-template-columns: auto auto; } #mb-footer .footer-container a { margin-left: 2em; } #mb-footer .footer-link { text-align: right; }`;
|
|
82
|
+
|
|
83
|
+
// --> media queries
|
|
84
|
+
style += `@media (max-width: 680px) { #mb-footer .footer-container { grid-template-columns: auto; }#mb-footer .footer-text, #mb-footer .footer-link { text-align: center; } } @media (max-width: 400px) { #mb-footer .footer-text, #mb-footer .footer-link { text-align: left; } #mb-footer span { display: block; } #mb-footer .footer-container a { margin: 0; } }`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// create the variables
|
|
88
|
+
const head = document.querySelector("head"),
|
|
89
|
+
sheet = document.createElement("style");
|
|
90
|
+
|
|
91
|
+
// add to the page
|
|
92
|
+
head.appendChild(sheet);
|
|
93
|
+
sheet.appendChild(document.createTextNode(style));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
// MARK: after the HTML appended to DOM
|
|
99
|
+
hook.doneEach(function () {
|
|
100
|
+
|
|
101
|
+
// set the scope
|
|
102
|
+
const contentScope = document.getElementById("mb-footer");
|
|
103
|
+
|
|
104
|
+
// if the scope is empty
|
|
105
|
+
if (!contentScope) { return; }
|
|
106
|
+
|
|
107
|
+
//
|
|
108
|
+
// MARK: - add the info
|
|
109
|
+
//
|
|
110
|
+
|
|
111
|
+
// get the date
|
|
112
|
+
const date = new Date().getFullYear(),
|
|
113
|
+
|
|
114
|
+
// -- url building
|
|
115
|
+
baseUrl = window.location.origin + window.location.pathname + "#/",
|
|
116
|
+
|
|
117
|
+
// -- check if link is internal or external
|
|
118
|
+
isExternalLink = (url) => {
|
|
119
|
+
const tmp = document.createElement('a');
|
|
120
|
+
tmp.href = url;
|
|
121
|
+
return tmp.host !== window.location.host;
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
// -- link generator
|
|
125
|
+
createLink = (option, linkText, defaultLink, className) => {
|
|
126
|
+
let result = "";
|
|
127
|
+
|
|
128
|
+
// --> only accept bool and string
|
|
129
|
+
if (typeof option === "boolean" || typeof option === "string") {
|
|
130
|
+
|
|
131
|
+
// --> if bool, and true
|
|
132
|
+
if (typeof option === "boolean" && option) {
|
|
133
|
+
|
|
134
|
+
// --> use the default options
|
|
135
|
+
result = `<a href="${baseUrl + defaultLink}">${linkText}</a>`;
|
|
136
|
+
|
|
137
|
+
// --> if it is a string url
|
|
138
|
+
} else if (typeof option === "string") {
|
|
139
|
+
|
|
140
|
+
// --> is the link external
|
|
141
|
+
result = isExternalLink(option)
|
|
142
|
+
|
|
143
|
+
// --> if external, add the _blank
|
|
144
|
+
? `<a target="_blank" href="${option}">${linkText}</a>`
|
|
145
|
+
|
|
146
|
+
// --> if internal, then add the page name
|
|
147
|
+
: `<a href="${baseUrl + option}">${linkText}</a>`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// --> if the result is not empty
|
|
152
|
+
if (result) {
|
|
153
|
+
|
|
154
|
+
// --> create the class name
|
|
155
|
+
const classname = `${className.toLowerCase().replace(/\s+/g, '-')}`;
|
|
156
|
+
|
|
157
|
+
// -- compile the elements
|
|
158
|
+
result = `<span class="${classname}">${result}</span>`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return result;
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
// MARK: - html elements
|
|
165
|
+
|
|
166
|
+
divclose = `</div>`,
|
|
167
|
+
|
|
168
|
+
// -- divs
|
|
169
|
+
div1open = `<div class="footer-container">`,
|
|
170
|
+
div2open = `<div class="footer-text">`,
|
|
171
|
+
div3open = `<div class="footer-link">`,
|
|
172
|
+
|
|
173
|
+
// -- text
|
|
174
|
+
copyright = (
|
|
175
|
+
`<span class="footer-text-copyright">Copyright © ${
|
|
176
|
+
options.copyYear && options.copyYear <= date
|
|
177
|
+
? `${options.copyYear}${options.copyYear < date ? "-" + date : ""}`
|
|
178
|
+
: date
|
|
179
|
+
}</span>`
|
|
180
|
+
),
|
|
181
|
+
author = createLink( options.url, options.name, '', 'footer-text-author'),
|
|
182
|
+
|
|
183
|
+
// -- links
|
|
184
|
+
policyURL = createLink(options.policy, 'Policy', '_policy', 'footer-links-policy'),
|
|
185
|
+
termsURL = createLink(options.terms, 'Terms', '_terms', 'footer-links-terms' ),
|
|
186
|
+
cookiesURL = createLink(options.cookies, 'Cookies', '_cookies', 'footer-links-cookies'),
|
|
187
|
+
|
|
188
|
+
// output
|
|
189
|
+
output = (
|
|
190
|
+
div1open +
|
|
191
|
+
div2open + copyright + author + divclose +
|
|
192
|
+
div3open + policyURL + termsURL + cookiesURL + divclose +
|
|
193
|
+
divclose
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
contentScope.innerHTML = output;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
// MARK: - check options is defined and not empty
|
|
202
|
+
if (typeof options !== 'undefined' && doesObjectExists(options)) {
|
|
203
|
+
|
|
204
|
+
// -- find footer plugin options
|
|
205
|
+
window.$docsify.autoFooter = Object.assign(
|
|
206
|
+
options,
|
|
207
|
+
window.$docsify.autoFooter
|
|
208
|
+
);
|
|
209
|
+
window.$docsify.plugins = [].concat(autoFooter, window.$docsify.plugins);
|
|
210
|
+
|
|
211
|
+
} else {
|
|
212
|
+
|
|
213
|
+
// -- log the error
|
|
214
|
+
console.error(
|
|
215
|
+
"ERROR: sidebar-footer configuration not set" + "\n" +
|
|
216
|
+
"This error appears when:" + "\n" +
|
|
217
|
+
" - the `autoSidebar` not found index.html file" + "\n" +
|
|
218
|
+
" - the `autoSidebar` is empty"
|
|
219
|
+
);
|
|
220
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* docsify-sidebarFooter.js v5.0.1 | (c) Mark Battistella */
|
|
2
|
+
"use strict";function doesObjectExists(o){return null!=o&&o.constructor===Object&&0<Object.keys(o).length}function getFooter(o){(new Date).getFullYear();o.name,o.url,o.copyYear,o.policy,o.terms,o.cookies,o.customStyle}var options={name:"",url:"",copyYear:"",policy:!0,terms:!0,cookies:!0,customStyle:!1};function autoFooter(o,t){o.init(function(){var o,t,e;getFooter(options),"boolean"!=typeof options.customStyle&&"string"!=typeof options.customStyle||"boolean"==typeof options.customStyle&&!0===options.customStyle||(o="#mb-footer { border-top: 1px solid; font-size: 0.8em; line-height: 1.5; transition: all var(--sidebar-transition-duration) ease-out; }",("boolean"==typeof options.customStyle&&!1===options.customStyle||"sidebar"===options.customStyle)&&(o+="#mb-footer { padding-top: 1.5rem; margin-top: 1.5rem; } #mb-footer .footer-text, #mb-footer .footer-text a { font-weight: bold; }"),"body"===options.customStyle&&(!$docsify.loadSidebar&&null!==$docsify.loadSidebar&&$docsify.hideSidebar||(o+="body #mb-footer { margin-left: var(--sidebar-width); } body.close #mb-footer { margin-left: 0; }"),o+="#mb-footer { padding: 1.5rem; } #mb-footer .footer-container { max-width: var(--content-max-width); margin: 0 auto; } #mb-footer .footer-container { display: grid; grid-template-columns: auto auto; } #mb-footer .footer-container a { margin-left: 2em; } #mb-footer .footer-link { text-align: right; }@media (max-width: 680px) { #mb-footer .footer-container { grid-template-columns: auto; }#mb-footer .footer-text, #mb-footer .footer-link { text-align: center; } } @media (max-width: 400px) { #mb-footer .footer-text, #mb-footer .footer-link { text-align: left; } #mb-footer span { display: block; } #mb-footer .footer-container a { margin: 0; } }"),t=document.querySelector("head"),e=document.createElement("style"),t.appendChild(e),e.appendChild(document.createTextNode(o)))}),o.doneEach(function(){var r,a,o,t,e,n,i,s,c=document.getElementById("mb-footer");c&&(t=(new Date).getFullYear(),r=window.location.origin+window.location.pathname+"#/",a=function(o){var t=document.createElement("a");return t.href=o,t.host!==window.location.host},s=function(o,t,e,n){var i="";return"boolean"!=typeof o&&"string"!=typeof o||("boolean"==typeof o&&o?i='<a href="'.concat(r+e,'">').concat(t,"</a>"):"string"==typeof o&&(i=(a(o)?'<a target="_blank" href="'.concat(o,'">'):'<a href="'.concat(r+o,'">')).concat(t,"</a>"))),i&&(e="".concat(n.toLowerCase().replace(/\s+/g,"-")),i='<span class="'.concat(e,'">').concat(i,"</span>")),i},o="</div>",t='<span class="footer-text-copyright">Copyright © '.concat(options.copyYear&&options.copyYear<=t?"".concat(options.copyYear).concat(options.copyYear<t?"-"+t:""):t,"</span>"),e=s(options.url,options.name,"","footer-text-author"),n=s(options.policy,"Policy","_policy","footer-links-policy"),i=s(options.terms,"Terms","_terms","footer-links-terms"),s=s(options.cookies,"Cookies","_cookies","footer-links-cookies"),c.innerHTML='<div class="footer-container"><div class="footer-text">'+t+e+o+'<div class="footer-link">'+n+i+s+o+o)})}void 0!==options&&doesObjectExists(options)?(window.$docsify.autoFooter=Object.assign(options,window.$docsify.autoFooter),window.$docsify.plugins=[].concat(autoFooter,window.$docsify.plugins)):console.error("ERROR: sidebar-footer configuration not set\nThis error appears when:\n - the `autoSidebar` not found index.html file\n - the `autoSidebar` is empty");
|
package/package.json
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markbattistella/docsify-sidebarfooter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Add a footer notice for Docsify.js",
|
|
5
|
-
"main": "dist/docsify-
|
|
5
|
+
"main": "./dist/docsify-sidebar.min.js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/markbattistella/docsify-sidebarFooter.git"
|
|
9
9
|
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"url": "https://github.com/markbattistella/docsify-sidebarFooter/issues"
|
|
14
|
-
},
|
|
15
|
-
"homepage": "https://github.com/markbattistella/docsify-sidebarFooter#readme",
|
|
10
|
+
"scripts": {},
|
|
11
|
+
"unpkg": "./dist/docsify-sidebar.min.js",
|
|
12
|
+
"jsdelivr": "./dist/docsify-sidebar.min.js",
|
|
16
13
|
"keywords": [
|
|
17
14
|
"footer",
|
|
18
15
|
"copyright",
|
|
19
16
|
"privacy policy",
|
|
20
17
|
"terms of service",
|
|
18
|
+
"terms and conditions",
|
|
19
|
+
"terms",
|
|
20
|
+
"policy",
|
|
21
|
+
"cookie",
|
|
21
22
|
"cookie policy",
|
|
22
23
|
"docsify",
|
|
23
24
|
"docsify plugin"
|
|
24
|
-
]
|
|
25
|
+
],
|
|
26
|
+
"author": "Mark Battistella",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/markbattistella/docsify-sidebar-footer/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://footer.docsify.markbattistella.com"
|
|
25
32
|
}
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
/*! docsify-sidebarFooter.js v4.0.0 | (c) Mark Battistella */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
function getFooter( footerOptions ) {
|
|
5
|
-
|
|
6
|
-
// if it is empty
|
|
7
|
-
if(
|
|
8
|
-
!footerOptions.name ||
|
|
9
|
-
!footerOptions.copyYear
|
|
10
|
-
) {
|
|
11
|
-
return 'No config set'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// get this year
|
|
15
|
-
let date = new Date().getFullYear();
|
|
16
|
-
|
|
17
|
-
// create the array variables
|
|
18
|
-
let name = footerOptions.name ?
|
|
19
|
-
footerOptions.name : null;
|
|
20
|
-
let url = footerOptions.url ?
|
|
21
|
-
footerOptions.url : null;
|
|
22
|
-
let copyYear = footerOptions.copyYear ?
|
|
23
|
-
footerOptions.copyYear : date;
|
|
24
|
-
let policy = footerOptions.policy ?
|
|
25
|
-
footerOptions.policy : null;
|
|
26
|
-
let terms = footerOptions.terms ?
|
|
27
|
-
footerOptions.terms : null;
|
|
28
|
-
let cookies = footerOptions.cookies ?
|
|
29
|
-
footerOptions.cookies : null;
|
|
30
|
-
let onBody = footerOptions.onBody ?
|
|
31
|
-
footerOptions.onBody : false;
|
|
32
|
-
|
|
33
|
-
// build the array
|
|
34
|
-
var outputArray = [
|
|
35
|
-
name,
|
|
36
|
-
url,
|
|
37
|
-
copyYear,
|
|
38
|
-
policy,
|
|
39
|
-
terms,
|
|
40
|
-
cookies,
|
|
41
|
-
onBody
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
return outputArray;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// defaults - and setup
|
|
48
|
-
const footerOptions = {
|
|
49
|
-
name: '', // required
|
|
50
|
-
url: '', // optional
|
|
51
|
-
copyYear: '', // required
|
|
52
|
-
policy: false, // optional
|
|
53
|
-
terms: false, // optional
|
|
54
|
-
cookies: false, // optional
|
|
55
|
-
onBody: false // optional
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// the function
|
|
60
|
-
function autoFooter( hook, vm ) {
|
|
61
|
-
|
|
62
|
-
// get the variables from the cofig
|
|
63
|
-
const footerOptionsArray = getFooter( footerOptions ),
|
|
64
|
-
|
|
65
|
-
// create them easier to read
|
|
66
|
-
arrayName = footerOptionsArray[0],
|
|
67
|
-
arrayUrl = footerOptionsArray[1],
|
|
68
|
-
arrayCopyYear = footerOptionsArray[2],
|
|
69
|
-
arrayPolicy = footerOptionsArray[3],
|
|
70
|
-
arrayTerms = footerOptionsArray[4],
|
|
71
|
-
arrayCookies = footerOptionsArray[5],
|
|
72
|
-
arraySidebar = footerOptionsArray[6];
|
|
73
|
-
|
|
74
|
-
// when script starts running
|
|
75
|
-
hook.init(function() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function rgb2hex( rgb ) {
|
|
80
|
-
rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
|
|
81
|
-
function hex(x) {
|
|
82
|
-
return ("0" + parseInt(x).toString(16)).slice(-2);
|
|
83
|
-
}
|
|
84
|
-
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// detect if we have a light or dark text
|
|
90
|
-
// -- https://stackoverflow.com/a/35970186/1086990
|
|
91
|
-
function invertColor( hex, bw ) {
|
|
92
|
-
if (hex.indexOf('#') === 0) {
|
|
93
|
-
hex = hex.slice(1);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// convert 3-digit hex to 6-digits.
|
|
97
|
-
if( hex.length === 3 ) {
|
|
98
|
-
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// no background colour: default white
|
|
102
|
-
if( hex.length === 0 ) {
|
|
103
|
-
hex = "FFFFFF"
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// not HEX or greater than 6 chars
|
|
107
|
-
if( hex.length !== 6 ) {
|
|
108
|
-
|
|
109
|
-
hex = rgb2hex( hex );
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// throw new Error('Invalid HEX color.');
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// get the RGB values
|
|
116
|
-
var r = parseInt(hex.slice(0, 2), 16),
|
|
117
|
-
g = parseInt(hex.slice(2, 4), 16),
|
|
118
|
-
b = parseInt(hex.slice(4, 6), 16);
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
if( bw ) {
|
|
122
|
-
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
|
|
123
|
-
? '#000000'
|
|
124
|
-
: '#FFFFFF';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const zeros = new Array(2).join('0');
|
|
128
|
-
|
|
129
|
-
// invert color components
|
|
130
|
-
r = (zeros + (( 255 - r ).toString(16))).slice(-2),
|
|
131
|
-
g = (zeros + (( 255 - g ).toString(16))).slice(-2),
|
|
132
|
-
b = (zeros + (( 255 - b ).toString(16))).slice(-2);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// pad each with zeros and return
|
|
136
|
-
return "#" + r + g + b;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// add in the style
|
|
141
|
-
if( typeof arraySidebar === "boolean" && arraySidebar ) {
|
|
142
|
-
|
|
143
|
-
// create the variables
|
|
144
|
-
const head = document.querySelector( "head" ),
|
|
145
|
-
sheet = document.createElement( "style" ),
|
|
146
|
-
|
|
147
|
-
// body background and inverse
|
|
148
|
-
bodyBG = (document.body.style.backgroundColor === "" ? "#FFF" : document.body.style.backgroundColor ),
|
|
149
|
-
bodyIBG = invertColor( bodyBG, true ),
|
|
150
|
-
|
|
151
|
-
// styling
|
|
152
|
-
style = "#mb-footer { position: fixed; bottom: 0; left: 50%; border-radius: 10em 10em 0 0; max-width: var(--content-max-width, 800px); width: 100%; padding: 0 45px; text-align: center; box-shadow: 0 -1em 1em 0 rgba(0,0,0,0.05); transform: translateX(-50%); background: " + bodyBG + "; line-height: 2em; } #mb-footer, #mb-footer a { color: " + bodyIBG + "; } #mb-footer > div > div, #mb-footer > div a { display: inline-block; margin-right: 1em; } @media( max-width: 430px ){ #mb-footer { position: relative; left: auto; transform: none; } #mb-footer span { display: inline-block; } }";
|
|
153
|
-
|
|
154
|
-
// add to the page
|
|
155
|
-
head.appendChild( sheet );
|
|
156
|
-
sheet.appendChild( document.createTextNode( style ) );
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// after initial completion
|
|
162
|
-
hook.doneEach(function() {
|
|
163
|
-
|
|
164
|
-
//
|
|
165
|
-
// MARK: - set the scope of the autoFooter
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
// set the scope
|
|
169
|
-
const contentScope = document.getElementById("mb-footer");
|
|
170
|
-
|
|
171
|
-
// if the scope is empty
|
|
172
|
-
if( !contentScope ) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// if the array doesnt have the minimum entries
|
|
177
|
-
if( footerOptionsArray === "No config set" ) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
//
|
|
183
|
-
// MARK: - add the info
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
// get the date
|
|
187
|
-
const date = new Date().getFullYear(),
|
|
188
|
-
|
|
189
|
-
// url building
|
|
190
|
-
baseUrl = window.location.origin + window.location.pathname + "#/",
|
|
191
|
-
|
|
192
|
-
// divider
|
|
193
|
-
a = ( (typeof arraySidebar === "boolean" && arraySidebar) ? "" : "<hr/>"),
|
|
194
|
-
|
|
195
|
-
// create the footer
|
|
196
|
-
b = "<div style='font-size:70%;'>",
|
|
197
|
-
|
|
198
|
-
// copyright data
|
|
199
|
-
c = "<div>",
|
|
200
|
-
|
|
201
|
-
d = "© ",
|
|
202
|
-
|
|
203
|
-
// get the start copy year
|
|
204
|
-
// --> if is empty OR greater than current year
|
|
205
|
-
e = ( (arrayCopyYear == null) || (arrayCopyYear > date) ? date : arrayCopyYear ),
|
|
206
|
-
|
|
207
|
-
// get the current year
|
|
208
|
-
// --> do we add the "-YYYY" range or not
|
|
209
|
-
f = ( (arrayCopyYear != null) && (arrayCopyYear < date) ? "—" + date : ""),
|
|
210
|
-
|
|
211
|
-
g = "</div>",
|
|
212
|
-
|
|
213
|
-
// company details
|
|
214
|
-
h = ( arrayUrl == null ? "<div>" :
|
|
215
|
-
"<a target='_blank' href='" + arrayUrl + "'>" ),
|
|
216
|
-
|
|
217
|
-
i = arrayName,
|
|
218
|
-
|
|
219
|
-
j = ( arrayUrl === "" ? "</div>" : "</a>" ),
|
|
220
|
-
|
|
221
|
-
// policy details
|
|
222
|
-
k = ( typeof arrayPolicy === "boolean" ||
|
|
223
|
-
typeof arrayPolicy === "string"
|
|
224
|
-
) ?
|
|
225
|
-
( typeof arrayPolicy === "boolean" ?
|
|
226
|
-
"<a href='" + baseUrl + "_policy'>Policy</a>"
|
|
227
|
-
:
|
|
228
|
-
"<a href='" + baseUrl + arrayPolicy + "'>Policy</a>"
|
|
229
|
-
) : "",
|
|
230
|
-
|
|
231
|
-
// terms details
|
|
232
|
-
l = ( typeof arrayTerms === "boolean" ||
|
|
233
|
-
typeof arrayTerms === "string"
|
|
234
|
-
) ?
|
|
235
|
-
( typeof arrayTerms === "boolean" ?
|
|
236
|
-
"<a href='" + baseUrl + "_terms'>Terms</a>"
|
|
237
|
-
:
|
|
238
|
-
"<a href='" + baseUrl + arrayTerms + "'>Terms</a>"
|
|
239
|
-
) : "",
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
// cookies details
|
|
243
|
-
m = ( typeof arrayCookies === "boolean" ||
|
|
244
|
-
typeof arrayCookies === "string"
|
|
245
|
-
) ?
|
|
246
|
-
( typeof arrayTerms === "boolean" ?
|
|
247
|
-
"<a href='" + baseUrl + "_cookies'>Cookies</a>"
|
|
248
|
-
:
|
|
249
|
-
"<a href='" + baseUrl + arrayCookies + "'>Cookies</a>"
|
|
250
|
-
) : "",
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
n = "</div>";
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// output them to the body
|
|
257
|
-
const output =
|
|
258
|
-
a + // ------------------
|
|
259
|
-
b + c + //
|
|
260
|
-
d + e + f + // (c) 1990-2020
|
|
261
|
-
g + //
|
|
262
|
-
h + i + j + // Company Name
|
|
263
|
-
"<span>" +
|
|
264
|
-
k + // Policy
|
|
265
|
-
l + // Terms
|
|
266
|
-
m + // Cookies
|
|
267
|
-
"</span>" +
|
|
268
|
-
n; //
|
|
269
|
-
|
|
270
|
-
contentScope.innerHTML = output;
|
|
271
|
-
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
// find footer plugin options
|
|
277
|
-
window.$docsify.autoFooter = Object.assign(
|
|
278
|
-
footerOptions,
|
|
279
|
-
window.$docsify.autoFooter
|
|
280
|
-
);
|
|
281
|
-
window.$docsify.plugins = [].concat(autoFooter, window.$docsify.plugins);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/* docsify-sidebarFooter.js v4.0.0 | (c) Mark Battistella */
|
|
2
|
-
function getFooter(b){if(!b.name||!b.copyYear)return"No config set";var w=(new Date).getFullYear();return[b.name?b.name:null,b.url?b.url:null,b.copyYear?b.copyYear:w,b.policy?b.policy:null,b.terms?b.terms:null,b.cookies?b.cookies:null,b.onBody?b.onBody:!1]}var footerOptions={name:"",url:"",copyYear:"",policy:!1,terms:!1,cookies:!1,onBody:!1};
|
|
3
|
-
function autoFooter(b,w){var c=getFooter(footerOptions),y=c[0],t=c[1],g=c[2],l=c[3],h=c[4],u=c[5],m=c[6];b.init(function(){function n(a){function k(e){return("0"+parseInt(e).toString(16)).slice(-2)}a=a.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);return"#"+k(a[1])+k(a[2])+k(a[3])}function f(a,k){0===a.indexOf("#")&&(a=a.slice(1));3===a.length&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]);0===a.length&&(a="FFFFFF");6!==a.length&&(a=n(a));var e=parseInt(a.slice(0,2),16),p=parseInt(a.slice(2,4),16),
|
|
4
|
-
q=parseInt(a.slice(4,6),16);if(k)return 186<.299*e+.587*p+.114*q?"#000000":"#FFFFFF";var v=Array(2).join("0");e=(v+(255-e).toString(16)).slice(-2);p=(v+(255-p).toString(16)).slice(-2);q=(v+(255-q).toString(16)).slice(-2);return"#"+e+p+q}if("boolean"===typeof m&&m){var d=document.querySelector("head"),x=document.createElement("style"),r=""===document.body.style.backgroundColor?"#FFF":document.body.style.backgroundColor,z=f(r,!0);r="#mb-footer { position: fixed; bottom: 0; left: 50%; border-radius: 10em 10em 0 0; max-width: var(--content-max-width, 800px); width: 100%; padding: 0 45px; text-align: center; box-shadow: 0 -1em 1em 0 rgba(0,0,0,0.05); transform: translateX(-50%); background: "+
|
|
5
|
-
r+"; line-height: 2em; } #mb-footer, #mb-footer a { color: "+z+"; } #mb-footer > div > div, #mb-footer > div a { display: inline-block; margin-right: 1em; } @media( max-width: 430px ){ #mb-footer { position: relative; left: auto; transform: none; } #mb-footer span { display: inline-block; } }";d.appendChild(x);x.appendChild(document.createTextNode(r))}});b.doneEach(function(){var n=document.getElementById("mb-footer");if(n&&"No config set"!==c){var f=(new Date).getFullYear(),d=window.location.origin+
|
|
6
|
-
window.location.pathname+"#/";n.innerHTML=("boolean"===typeof m&&m?"":"<hr/>")+"<div style='font-size:70%;'><div>© "+(null==g||g>f?f:g)+(null!=g&&g<f?"—"+f:"")+"</div>"+(null==t?"<div>":"<a target='_blank' href='"+t+"'>")+y+(""===t?"</div>":"</a>")+"<span>"+("boolean"===typeof l||"string"===typeof l?"boolean"===typeof l?"<a href='"+d+"_policy'>Policy</a>":"<a href='"+d+l+"'>Policy</a>":"")+("boolean"===typeof h||"string"===typeof h?"boolean"===typeof h?"<a href='"+d+"_terms'>Terms</a>":
|
|
7
|
-
"<a href='"+d+h+"'>Terms</a>":"")+("boolean"===typeof u||"string"===typeof u?"boolean"===typeof h?"<a href='"+d+"_cookies'>Cookies</a>":"<a href='"+d+u+"'>Cookies</a>":"")+"</span></div>"}})}window.$docsify.autoFooter=Object.assign(footerOptions,window.$docsify.autoFooter);window.$docsify.plugins=[].concat(autoFooter,window.$docsify.plugins);
|