@markbattistella/docsify-sidebarfooter 5.0.6 → 5.0.7

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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 5.0.7 - Sat May 25 2024
2
+
3
+ ### Fixed
4
+
5
+ - Documentation cleanup
1
6
 
2
7
  ## 5.0.6 - Mon May 22 2023
3
8
 
@@ -0,0 +1,184 @@
1
+ /*! docsify-sidebar 5.0.7 | (c) Mark Battistella */
2
+ ; (function () {
3
+ 'use strict';
4
+
5
+ const autoFooter = (hook, vm) => {
6
+ // Default options
7
+ const footerOptions = {
8
+ name: '',
9
+ url: '',
10
+ copyYear: '',
11
+ policy: true,
12
+ terms: true,
13
+ cookies: true,
14
+ customStyle: 'body'
15
+ };
16
+
17
+ // Extend defaults with user options
18
+ Object.assign(footerOptions, $docsify.autoFooter || {});
19
+
20
+ const isObject = (obj) => obj && obj.constructor === Object && Object.keys(obj).length > 0;
21
+
22
+ if (!isObject(footerOptions)) {
23
+ throw new Error('Sidebar-footer configuration is invalid or empty. Please check the $docsify.autoFooter config.');
24
+ }
25
+
26
+ // Auto-update the year
27
+ if (!footerOptions.copyYear) {
28
+ footerOptions.copyYear = new Date().getFullYear();
29
+ }
30
+
31
+ // MARK: run with docsify init
32
+ hook.init(function () {
33
+
34
+ // -- initialise the options
35
+ // getFooter(footerOptions, $docsify.autoFooter || {});
36
+
37
+ // -- check the options for bool or string
38
+ if (typeof footerOptions.customStyle === "boolean" || typeof footerOptions.customStyle === "string") {
39
+
40
+ // -- dont continue if using custom styles
41
+ if ((typeof footerOptions.customStyle === "boolean" && footerOptions.customStyle === true)) {
42
+ return;
43
+ }
44
+
45
+ // -- global style
46
+ let style = `#mb-footer { border-top: 1px solid; font-size: 0.8em; line-height: 1.5; transition: all var(--sidebar-transition-duration) ease-out; }`;
47
+
48
+ // -- custom style for sidebar
49
+ if ((typeof footerOptions.customStyle === "boolean" && footerOptions.customStyle === false) ||
50
+ (footerOptions.customStyle === "sidebar")
51
+ ) {
52
+ style += `#mb-footer { padding-top: 1.5rem; margin-top: 1.5rem; } #mb-footer .footer-text, #mb-footer .footer-text a { font-weight: bold; }`;
53
+ }
54
+
55
+ // -- custom style for sidebar
56
+ if (footerOptions.customStyle === "body") {
57
+
58
+ // --> if there is a sidebar
59
+ if ($docsify.loadSidebar || $docsify.loadSidebar === null || !$docsify.hideSidebar) {
60
+ style += `body #mb-footer { margin-left: var(--sidebar-width); } body.close #mb-footer { margin-left: 0; }`;
61
+ }
62
+
63
+ // --> standard
64
+ 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; }`;
65
+
66
+ // --> media queries
67
+ 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; } }`;
68
+ }
69
+
70
+ // create the variables
71
+ const head = document.querySelector("head"),
72
+ sheet = document.createElement("style");
73
+
74
+ // add to the page
75
+ head.appendChild(sheet);
76
+ sheet.appendChild(document.createTextNode(style));
77
+ }
78
+ });
79
+
80
+ // MARK: after the HTML appended to DOM
81
+ hook.doneEach(function () {
82
+
83
+ // set the scope
84
+ const contentScope = document.getElementById("mb-footer");
85
+
86
+ // if the scope is empty
87
+ if (!contentScope) { return; }
88
+
89
+ //
90
+ // MARK: - add the info
91
+ //
92
+
93
+ // get the date
94
+ const date = new Date().getFullYear(),
95
+
96
+ // -- url building
97
+ baseUrl = window.location.origin + window.location.pathname + "#/",
98
+
99
+ // -- check if link is internal or external
100
+ isExternalLink = (url) => {
101
+ const tmp = document.createElement('a');
102
+ tmp.href = url;
103
+ return tmp.host !== window.location.host;
104
+ },
105
+
106
+ // -- link generator
107
+ createLink = (option, linkText, defaultLink, className) => {
108
+ let result = "";
109
+
110
+ // --> only accept bool and string
111
+ if (typeof option === "boolean" || typeof option === "string") {
112
+
113
+ // --> if bool, and true
114
+ if (typeof option === "boolean" && option) {
115
+
116
+ // --> use the default options
117
+ result = `<a href="${baseUrl + defaultLink}">${linkText}</a>`;
118
+
119
+ // --> if it is a string url
120
+ } else if (typeof option === "string") {
121
+
122
+ // --> is the link external
123
+ result = isExternalLink(option)
124
+
125
+ // --> if external, add the _blank
126
+ ? `<a target="_blank" href="${option}">${linkText}</a>`
127
+
128
+ // --> if internal, then add the page name
129
+ : `<a href="${baseUrl + option}">${linkText}</a>`;
130
+ }
131
+ }
132
+
133
+ // --> if the result is not empty
134
+ if (result) {
135
+
136
+ // --> create the class name
137
+ const classname = `${className.toLowerCase().replace(/\s+/g, '-')}`;
138
+
139
+ // -- compile the elements
140
+ result = `<span class="${classname}">${result}</span>`;
141
+ }
142
+
143
+ return result;
144
+ },
145
+
146
+ // MARK: - html elements
147
+
148
+ divclose = `</div>`,
149
+
150
+ // -- divs
151
+ div1open = `<div class="footer-container">`,
152
+ div2open = `<div class="footer-text">`,
153
+ div3open = `<div class="footer-link">`,
154
+
155
+ // -- text
156
+ copyright = (
157
+ `<span class="footer-text-copyright">Copyright &copy; ${footerOptions.copyYear && footerOptions.copyYear <= date
158
+ ? `${footerOptions.copyYear}${footerOptions.copyYear < date ? "&#45;" + date : ""}`
159
+ : date
160
+ }</span>`
161
+ ),
162
+ author = createLink(footerOptions.url, footerOptions.name, '', 'footer-text-author'),
163
+
164
+ // -- links
165
+ policyURL = createLink(footerOptions.policy, 'Policy', '_policy', 'footer-links-policy'),
166
+ termsURL = createLink(footerOptions.terms, 'Terms', '_terms', 'footer-links-terms'),
167
+ cookiesURL = createLink(footerOptions.cookies, 'Cookies', '_cookies', 'footer-links-cookies'),
168
+
169
+ // output
170
+ output = (
171
+ div1open +
172
+ div2open + copyright + author + divclose +
173
+ div3open + policyURL + termsURL + cookiesURL + divclose +
174
+ divclose
175
+ );
176
+
177
+ contentScope.innerHTML = output;
178
+ });
179
+ }
180
+
181
+ // Register the plugin
182
+ $docsify = $docsify || {};
183
+ $docsify.plugins = [].concat(autoFooter, $docsify.plugins || []);
184
+ }());
@@ -1,2 +1,2 @@
1
- /*! docsify-sidebar 5.0.6 | (c) Mark Battistella */
1
+ /*! docsify-sidebar 5.0.7 | (c) Mark Battistella */
2
2
  "use strict";($docsify=$docsify||{}).plugins=[].concat(function(o,t){var e,s={name:"",url:"",copyYear:"",policy:!0,terms:!0,cookies:!0,customStyle:"body"};Object.assign(s,$docsify.autoFooter||{});if(!((e=s)&&e.constructor===Object&&0<Object.keys(e).length))throw new Error("Sidebar-footer configuration is invalid or empty. Please check the $docsify.autoFooter config.");s.copyYear||(s.copyYear=(new Date).getFullYear()),o.init(function(){var o,t,e;"boolean"!=typeof s.customStyle&&"string"!=typeof s.customStyle||"boolean"==typeof s.customStyle&&!0===s.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 s.customStyle&&!1===s.customStyle||"sidebar"===s.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"===s.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 n,i,o,t,e,r,a,c,l=document.getElementById("mb-footer");l&&(t=(new Date).getFullYear(),n=window.location.origin+window.location.pathname+"#/",i=function(o){var t=document.createElement("a");return t.href=o,t.host!==window.location.host},c=function(o,t,e,r){var a="";return"boolean"!=typeof o&&"string"!=typeof o||("boolean"==typeof o&&o?a='<a href="'.concat(n+e,'">').concat(t,"</a>"):"string"==typeof o&&(a=(i(o)?'<a target="_blank" href="'.concat(o,'">'):'<a href="'.concat(n+o,'">')).concat(t,"</a>"))),a&&(e="".concat(r.toLowerCase().replace(/\s+/g,"-")),a='<span class="'.concat(e,'">').concat(a,"</span>")),a},o="</div>",t='<span class="footer-text-copyright">Copyright &copy; '.concat(s.copyYear&&s.copyYear<=t?"".concat(s.copyYear).concat(s.copyYear<t?"&#45;"+t:""):t,"</span>"),e=c(s.url,s.name,"","footer-text-author"),r=c(s.policy,"Policy","_policy","footer-links-policy"),a=c(s.terms,"Terms","_terms","footer-links-terms"),c=c(s.cookies,"Cookies","_cookies","footer-links-cookies"),l.innerHTML='<div class="footer-container"><div class="footer-text">'+t+e+o+'<div class="footer-link">'+r+a+c+o+o)})},$docsify.plugins||[]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markbattistella/docsify-sidebarfooter",
3
- "version": "5.0.6",
3
+ "version": "5.0.7",
4
4
  "description": "Add a footer notice for Docsify.js",
5
5
  "main": "./dist/docsify-sidebar.min.js",
6
6
  "repository": {
@@ -12,9 +12,7 @@
12
12
  "update": "ncu -u && npm update && npm install",
13
13
  "babel": "npx babel ./docs/dist/docsify-sidebar.js -o ./docs/dist/docsify-sidebar.babel.js",
14
14
  "uglify": "uglifyjs ./docs/dist/docsify-sidebar.babel.js --verbose -c -m -o ./docs/dist/docsify-sidebar.min.js",
15
- "dupeJS": "mkdir -p ./dist/ && cp ./docs/dist/docsify-sidebar.min.js ./dist/docsify-sidebar.min.js",
16
- "dupeRM": "cp ./docs/README.md ./README.md",
17
- "minify": "npm run babel && npm run uglify && npm run dupeJS && npm run dupeRM",
15
+ "minify": "npm run babel && npm run uglify",
18
16
  "patch": "node ./.github/scripts/release.js -patch",
19
17
  "minor": "node ./.github/scripts/release.js -minor",
20
18
  "major": "node ./.github/scripts/release.js -major"