Skip to content

Commit ef9c17a

Browse files
2024-05-25 - Docs cleanup
1 parent 3adf684 commit ef9c17a

File tree

8 files changed

+4727
-4542
lines changed

8 files changed

+4727
-4542
lines changed

.github/scripts/release.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ packageData.version = newVersion;
3131
jsonfile.writeFileSync(packageFile, packageData, { spaces: 2 });
3232

3333
const filesToUpdate = [
34-
"./docs/dist/docsify-sidebar.js",
35-
"./docs/dist/docsify-sidebar.min.js",
34+
"./dist/docsify-sidebar.js",
3635
"./dist/docsify-sidebar.min.js"
3736
];
3837

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
.DS_Store
44
*babel.js
55
*.min.js
6-
!docs/dist
7-
!docs/dist/*.min.js
6+
.gitattributes

.markdownlint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"default": true,
33
"MD013": false,
44
"MD024": {
5-
"allow_different_nesting": true
5+
"siblings_only": true
66
},
77
"MD033": false,
88
"MD041": false,

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 5.0.7 - Sat May 25 2024
2+
3+
### Fixed
4+
5+
- Documentation cleanup
16

27
## 5.0.6 - Mon May 22 2023
38

dist/docsify-sidebar.js

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}());

dist/docsify-sidebar.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)