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

Commit 182aa6b

Browse files
committed
Create new base index that redirects
1 parent ac086c7 commit 182aa6b

File tree

11 files changed

+382
-32
lines changed

11 files changed

+382
-32
lines changed

build/postflight.js

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ const fs = require("fs");
2222
const jsdoc = require("jsdoc-api");
2323
const ejs = require("ejs");
2424

25+
const templateOptions = {
26+
name: "macOSNotifJS",
27+
packageName: name,
28+
version: version,
29+
dateOfBuild: new Date().toISOString().slice(0, 10),
30+
description: description,
31+
browsers: browserslist.map(x => {
32+
return [
33+
"https://browserl.ist/?q=" + encodeURIComponent(x),
34+
x,
35+
];
36+
}),
37+
};
38+
2539
const buildJSDoc = async position => {
2640
// Remove previous docs contents
2741
try {
@@ -44,29 +58,14 @@ const buildJSDoc = async position => {
4458
};
4559

4660
const injectDocsHome = async position => {
47-
// Create the template variables
48-
const dateOfBuild = new Date().toISOString().slice(0, 10);
49-
const projectName = "macOSNotifJS";
50-
const browsers = browserslist.map(x => {
51-
return [
52-
"https://browserl.ist/?q=" + encodeURIComponent(x),
53-
x,
54-
];
55-
});
56-
5761
// Render the template
5862
let html;
5963
try {
6064
const templateFile = "build/templates/docs-home.ejs";
6165
const template = fs.readFileSync(templateFile, "utf8");
6266
html = ejs.render(template, {
67+
...templateOptions,
6368
filename: templateFile,
64-
65-
name: projectName,
66-
version: version,
67-
dateOfBuild: dateOfBuild,
68-
description: description,
69-
browsers: browsers,
7069
});
7170
} catch (err) {
7271
console.error(chalk.red.bold(`\n${position} Failed to render custom homepage.`));
@@ -77,7 +76,9 @@ const injectDocsHome = async position => {
7776
try {
7877
const filePath = `docs/${name}/${version}/index.html`;
7978
let file = fs.readFileSync(filePath, "utf8");
80-
file = file.replace(`<h3>${name} ${version}</h3>`, html);
79+
file = file
80+
.replace(`<h3>${name} ${version}</h3>`, html)
81+
.replace("<title>", `<title>${name} - v${version} - `);
8182
fs.writeFileSync(filePath, file);
8283
} catch (err) {
8384
console.error(chalk.red.bold(`\n${position} Failed to inject custom homepage.`));
@@ -88,9 +89,29 @@ const injectDocsHome = async position => {
8889
console.log(chalk.greenBright.bold(`\n${position} Custom JSDoc homepage successfully rendered & injected.`));
8990
};
9091

92+
const createMainIndex = async position => {
93+
// Render the template
94+
try {
95+
const templateFile = "build/templates/main-index.ejs";
96+
const template = fs.readFileSync(templateFile, "utf8");
97+
const html = ejs.render(template, {
98+
...templateOptions,
99+
filename: templateFile,
100+
});
101+
fs.writeFileSync("index.html", html);
102+
} catch (err) {
103+
console.error(chalk.red.bold(`\n${position} Failed to render main index.`));
104+
throw err;
105+
}
106+
107+
// Done
108+
console.log(chalk.greenBright.bold(`\n${position} Successfully rendered main index file.`));
109+
};
110+
91111
const processes = [
92112
buildJSDoc,
93113
injectDocsHome,
114+
createMainIndex,
94115
];
95116

96117
const postFlight = async () => {

build/templates/includes/head.ejs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<meta charset="UTF-8"/>
22

3-
<title><%= `${name} - v ${version}` %></title>
3+
<title><%= `${name} - v${version}` %></title>
44

55
<meta name="title"
6-
content="<%= `${name} - v ${version}` %>"/>
6+
content="<%= `${name} - v${version}` %>"/>
77

88
<meta name="description"
9-
content="<%= `${name} - v ${version} - ${description}` %>"/>
9+
content="<%= `${name} - v${version} - ${description}` %>"/>
1010

1111
<meta name="keywords"
1212
content="javascript, javascript-plugin, notifications, notification, macos, javascript-tools, javascript-utility, javascript-audio, notification-system, simulated-macos-notifications, macosx, osx, osx-notifications, javascript-library, javascript-framework, notification-service, notification-api"/>
@@ -33,10 +33,10 @@
3333
content="@MattIPv4"/>
3434

3535
<meta name="twitter:title"
36-
content="<%= `${name} - v ${version}` %>"/>
36+
content="<%= `${name} - v${version}` %>"/>
3737

3838
<meta name="twitter:description"
39-
content="<%= `${name} - v ${version} - ${description}` %>"/>
39+
content="<%= `${name} - v${version} - ${description}` %>"/>
4040

4141
<meta name="twitter:image"
4242
content="https://macosnotif.js.org/brand/macOSNotifJS-818x162.png"/>
@@ -45,7 +45,7 @@
4545
content="https://macosnotif.js.org/"/>
4646

4747
<meta prefix="og: http://ogp.me/ns#" property="og:title"
48-
content="<%= `${name} - v ${version}` %>"/>
48+
content="<%= `${name} - v${version}` %>"/>
4949

5050
<meta prefix="og: http://ogp.me/ns#" property="og:type"
5151
content="website"/>
@@ -57,7 +57,7 @@
5757
content="<%= name %>"/>
5858

5959
<meta prefix="og: http://ogp.me/ns#" property="og:description"
60-
content="<%= `${name} - v ${version} - ${description}` %>"/>
60+
content="<%= `${name} - v${version} - ${description}` %>"/>
6161

6262
<meta prefix="og: http://ogp.me/ns#" property="og:url"
6363
content="https://macosnotif.js.org/"/>

build/templates/main-index.ejs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<% include includes/head %>
4+
<% include includes/style %>
5+
</html>
6+
<body>
7+
<% include includes/title %>
8+
<blockquote class="info">
9+
<h2 class="title">
10+
<a href="<%= `/docs/${packageName}/${version}/`%>">Redirecting to the latest docs...</a>
11+
</h2>
12+
</blockquote>
13+
<script>
14+
window.location.replace("<%= `/docs/${packageName}/${version}/`%>");
15+
</script>
16+
</body>

docs/macosnotif/0.1.1-beta1/Interact.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Interact.
14871487
<br class="clear">
14881488

14891489
<footer>
1490-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 17:34:59 GMT+0100 (British Summer Time)
1490+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 19:01:43 GMT+0100 (British Summer Time)
14911491
</footer>
14921492

14931493
<script> prettyPrint(); </script>

docs/macosnotif/0.1.1-beta1/Theme.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Interact.
654654
<br class="clear">
655655

656656
<footer>
657-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 17:34:59 GMT+0100 (British Summer Time)
657+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 19:01:43 GMT+0100 (British Summer Time)
658658
</footer>
659659

660660
<script> prettyPrint(); </script>

docs/macosnotif/0.1.1-beta1/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>JSDoc: Home</title>
5+
<title>macosnotif - v0.1.1-beta1 - JSDoc: Home</title>
66

77
<script src="scripts/prettify/prettify.js"> </script>
88
<script src="scripts/prettify/lang-css.js"> </script>
@@ -684,7 +684,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Interact.
684684
<br class="clear">
685685

686686
<footer>
687-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 17:34:59 GMT+0100 (British Summer Time)
687+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 19:01:43 GMT+0100 (British Summer Time)
688688
</footer>
689689

690690
<script> prettyPrint(); </script>

docs/macosnotif/0.1.1-beta1/interact.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Interact.
229229
<br class="clear">
230230

231231
<footer>
232-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 17:34:59 GMT+0100 (British Summer Time)
232+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 19:01:43 GMT+0100 (British Summer Time)
233233
</footer>
234234

235235
<script> prettyPrint(); </script>

docs/macosnotif/0.1.1-beta1/macOSNotif.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Interact.
710710
<br class="clear">
711711

712712
<footer>
713-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 17:34:59 GMT+0100 (British Summer Time)
713+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 19:01:43 GMT+0100 (British Summer Time)
714714
</footer>
715715

716716
<script> prettyPrint(); </script>

docs/macosnotif/0.1.1-beta1/macOSNotifJS.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Interact.
858858
<br class="clear">
859859

860860
<footer>
861-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 17:34:59 GMT+0100 (British Summer Time)
861+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 19:01:43 GMT+0100 (British Summer Time)
862862
</footer>
863863

864864
<script> prettyPrint(); </script>

docs/macosnotif/0.1.1-beta1/themes.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Interact.
152152
<br class="clear">
153153

154154
<footer>
155-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 17:34:59 GMT+0100 (British Summer Time)
155+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Sun Jun 09 2019 19:01:43 GMT+0100 (British Summer Time)
156156
</footer>
157157

158158
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)