fossbook 0.0.4 → 0.0.6
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 +246 -246
- package/bin/fossbook.js +120 -119
- package/lib/all_posts.js +33 -32
- package/lib/assets/placeholder.svg +3 -3
- package/lib/deploy.js +257 -237
- package/lib/home.js +60 -59
- package/lib/index.js +79 -79
- package/lib/init.js +311 -253
- package/lib/mod/config.js +136 -136
- package/lib/mod/marked.js +95 -95
- package/lib/mod/page.js +119 -115
- package/lib/mod/page_base.js +97 -97
- package/lib/new.js +48 -48
- package/lib/posts.js +47 -42
- package/lib/server.js +20 -14
- package/lib/tag/index.js +70 -69
- package/lib/tag/tag.js +30 -29
- package/package.json +45 -45
- package/themes/archie/assets/fonts/fira-sans-v10-latin-regular.svg +330 -330
- package/themes/archie/assets/fonts/ibm-plex-mono-v6-latin-500italic.svg +365 -365
- package/themes/archie/assets/fonts/roboto-mono-v12-latin-regular.svg +405 -405
- package/themes/archie/assets/styles/fonts.css +51 -51
- package/themes/archie/assets/styles/highlights.css +75 -75
- package/themes/archie/assets/styles/main.css +402 -402
- package/themes/archie/layouts/all_posts.html +41 -41
- package/themes/archie/layouts/home.html +61 -61
- package/themes/archie/layouts/page.html +50 -50
- package/themes/archie/layouts/partials/footer.html +9 -9
- package/themes/archie/layouts/post.html +81 -81
- package/themes/archie/layouts/tag.html +42 -42
- package/themes/archie/layouts/tag_list.html +43 -43
package/bin/fossbook.js
CHANGED
|
@@ -1,119 +1,120 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const { loadConfig } = require("../lib/mod/config");
|
|
5
|
-
|
|
6
|
-
const args = process.argv.slice(2);
|
|
7
|
-
const command = args[0];
|
|
8
|
-
|
|
9
|
-
function printHelp() {
|
|
10
|
-
console.log(`
|
|
11
|
-
Usage: fossbook <command> [options]
|
|
12
|
-
|
|
13
|
-
Commands:
|
|
14
|
-
build Build the static site
|
|
15
|
-
serve Build and start a local dev server
|
|
16
|
-
new <title> Create a new post
|
|
17
|
-
init
|
|
18
|
-
deploy Build, commit, push, and monitor deployment
|
|
19
|
-
|
|
20
|
-
Options:
|
|
21
|
-
-c, --config Path to config file (default: ./fossbook.config.js)
|
|
22
|
-
-o, --output Output directory (default: ./public)
|
|
23
|
-
-p, --port Dev server port (default: 3000)
|
|
24
|
-
--clean Remove output directory before build (default: true)
|
|
25
|
-
--github (init) Also create a GitHub repo and push
|
|
26
|
-
-m, --message (deploy) Custom commit message
|
|
27
|
-
--no-wait (deploy) Push without waiting for CI status
|
|
28
|
-
--draft (deploy) Commit locally without pushing
|
|
29
|
-
-v, --version Show version number
|
|
30
|
-
-h, --help Show help
|
|
31
|
-
`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getOption(flag, alias) {
|
|
35
|
-
const idx = args.indexOf(flag);
|
|
36
|
-
const aliasIdx = alias ? args.indexOf(alias) : -1;
|
|
37
|
-
const foundIdx = idx !== -1 ? idx : aliasIdx;
|
|
38
|
-
if (foundIdx !== -1 && foundIdx + 1 < args.length) {
|
|
39
|
-
return args[foundIdx + 1];
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function hasFlag(flag, alias) {
|
|
45
|
-
return args.includes(flag) || (alias && args.includes(alias));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (hasFlag("-v", "--version")) {
|
|
49
|
-
const pkg = require("../package.json");
|
|
50
|
-
console.log(`fossbook v${pkg.version}`);
|
|
51
|
-
process.exit(0);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (hasFlag("-h", "--help") || !command) {
|
|
55
|
-
printHelp();
|
|
56
|
-
process.exit(0);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const configPath = getOption("-c", "--config");
|
|
60
|
-
|
|
61
|
-
switch (command) {
|
|
62
|
-
case "build": {
|
|
63
|
-
const config = loadConfig(configPath);
|
|
64
|
-
const outputOverride = getOption("-o", "--output");
|
|
65
|
-
if (outputOverride) config.dev.outdir = outputOverride;
|
|
66
|
-
|
|
67
|
-
const { build } = require("../lib/index");
|
|
68
|
-
build(config);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
case "serve": {
|
|
73
|
-
const config = loadConfig(configPath);
|
|
74
|
-
const outputOverride = getOption("-o", "--output");
|
|
75
|
-
if (outputOverride) config.dev.outdir = outputOverride;
|
|
76
|
-
const port = getOption("-p", "--port") || 3000;
|
|
77
|
-
|
|
78
|
-
const { build } = require("../lib/index");
|
|
79
|
-
build(config);
|
|
80
|
-
|
|
81
|
-
const { serve } = require("../lib/server");
|
|
82
|
-
serve(config, Number(port));
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
case "new": {
|
|
87
|
-
const title = args[1];
|
|
88
|
-
if (!title) {
|
|
89
|
-
console.error('Error: Please provide a post title. Usage: fossbook new "My Post Title"');
|
|
90
|
-
process.exit(1);
|
|
91
|
-
}
|
|
92
|
-
const config = loadConfig(configPath);
|
|
93
|
-
const { createPost } = require("../lib/new");
|
|
94
|
-
createPost(config, title);
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
case "init": {
|
|
99
|
-
const { initProject } = require("../lib/init");
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
deploy(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { loadConfig } = require("../lib/mod/config");
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const command = args[0];
|
|
8
|
+
|
|
9
|
+
function printHelp() {
|
|
10
|
+
console.log(`
|
|
11
|
+
Usage: fossbook <command> [options]
|
|
12
|
+
|
|
13
|
+
Commands:
|
|
14
|
+
build Build the static site
|
|
15
|
+
serve Build and start a local dev server
|
|
16
|
+
new <title> Create a new post
|
|
17
|
+
init [name] Create a new fossbook site project
|
|
18
|
+
deploy Build, commit, push, and monitor deployment
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
-c, --config Path to config file (default: ./fossbook.config.js)
|
|
22
|
+
-o, --output Output directory (default: ./public)
|
|
23
|
+
-p, --port Dev server port (default: 3000)
|
|
24
|
+
--clean Remove output directory before build (default: true)
|
|
25
|
+
--github (init) Also create a GitHub repo and push
|
|
26
|
+
-m, --message (deploy) Custom commit message
|
|
27
|
+
--no-wait (deploy) Push without waiting for CI status
|
|
28
|
+
--draft (deploy) Commit locally without pushing
|
|
29
|
+
-v, --version Show version number
|
|
30
|
+
-h, --help Show help
|
|
31
|
+
`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getOption(flag, alias) {
|
|
35
|
+
const idx = args.indexOf(flag);
|
|
36
|
+
const aliasIdx = alias ? args.indexOf(alias) : -1;
|
|
37
|
+
const foundIdx = idx !== -1 ? idx : aliasIdx;
|
|
38
|
+
if (foundIdx !== -1 && foundIdx + 1 < args.length) {
|
|
39
|
+
return args[foundIdx + 1];
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function hasFlag(flag, alias) {
|
|
45
|
+
return args.includes(flag) || (alias && args.includes(alias));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (hasFlag("-v", "--version")) {
|
|
49
|
+
const pkg = require("../package.json");
|
|
50
|
+
console.log(`fossbook v${pkg.version}`);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (hasFlag("-h", "--help") || !command) {
|
|
55
|
+
printHelp();
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const configPath = getOption("-c", "--config");
|
|
60
|
+
|
|
61
|
+
switch (command) {
|
|
62
|
+
case "build": {
|
|
63
|
+
const config = loadConfig(configPath);
|
|
64
|
+
const outputOverride = getOption("-o", "--output");
|
|
65
|
+
if (outputOverride) config.dev.outdir = outputOverride;
|
|
66
|
+
|
|
67
|
+
const { build } = require("../lib/index");
|
|
68
|
+
build(config);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
case "serve": {
|
|
73
|
+
const config = loadConfig(configPath);
|
|
74
|
+
const outputOverride = getOption("-o", "--output");
|
|
75
|
+
if (outputOverride) config.dev.outdir = outputOverride;
|
|
76
|
+
const port = getOption("-p", "--port") || 3000;
|
|
77
|
+
|
|
78
|
+
const { build } = require("../lib/index");
|
|
79
|
+
build(config);
|
|
80
|
+
|
|
81
|
+
const { serve } = require("../lib/server");
|
|
82
|
+
serve(config, Number(port));
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
case "new": {
|
|
87
|
+
const title = args[1];
|
|
88
|
+
if (!title) {
|
|
89
|
+
console.error('Error: Please provide a post title. Usage: fossbook new "My Post Title"');
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
const config = loadConfig(configPath);
|
|
93
|
+
const { createPost } = require("../lib/new");
|
|
94
|
+
createPost(config, title);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
case "init": {
|
|
99
|
+
const { initProject } = require("../lib/init");
|
|
100
|
+
const projectName = !args[1] || args[1].startsWith("--") ? null : args[1];
|
|
101
|
+
initProject({ github: hasFlag("--github"), name: projectName });
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
case "deploy": {
|
|
106
|
+
const config = loadConfig(configPath);
|
|
107
|
+
const { deploy } = require("../lib/deploy");
|
|
108
|
+
deploy(config, {
|
|
109
|
+
message: getOption("-m", "--message"),
|
|
110
|
+
noWait: hasFlag("--no-wait"),
|
|
111
|
+
draft: hasFlag("--draft"),
|
|
112
|
+
});
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
default:
|
|
117
|
+
console.error(`Unknown command: ${command}`);
|
|
118
|
+
printHelp();
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
package/lib/all_posts.js
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const PageBase = require("./mod/page_base");
|
|
4
|
-
|
|
5
|
-
module.exports = class AllPostsPage extends PageBase {
|
|
6
|
-
constructor(config) {
|
|
7
|
-
super(config);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// posts: array of Page objects
|
|
11
|
-
generateContent(posts) {
|
|
12
|
-
const pageTitle = "All posts";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const PageBase = require("./mod/page_base");
|
|
4
|
+
|
|
5
|
+
module.exports = class AllPostsPage extends PageBase {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super(config);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// posts: array of Page objects
|
|
11
|
+
generateContent(posts) {
|
|
12
|
+
const pageTitle = "All posts";
|
|
13
|
+
const allPostsDir = path.join(this.config.dev.outdir, "all_posts");
|
|
14
|
+
if (!fs.existsSync(allPostsDir))
|
|
15
|
+
fs.mkdirSync(allPostsDir);
|
|
16
|
+
|
|
17
|
+
const data = { posts: posts, pageTitle: pageTitle };
|
|
18
|
+
this.url = `${this.config.blogsite}/posts.html`;
|
|
19
|
+
this.title = `${this.config.blogName}: ${data.pageTitle}`;
|
|
20
|
+
this.description = "All posts";
|
|
21
|
+
this.imageURL = this.config.image;
|
|
22
|
+
|
|
23
|
+
const templatePath = path.join(this.config.themePath, "layouts", "all_posts.html");
|
|
24
|
+
fs.writeFileSync(
|
|
25
|
+
path.join(allPostsDir, "index.html"),
|
|
26
|
+
this.generateHTML(templatePath, data),
|
|
27
|
+
(e) => {
|
|
28
|
+
if (e) throw e;
|
|
29
|
+
console.log(`posts.html was created successfully`);
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="400" viewBox="0 0 800 400">
|
|
2
|
-
<rect width="800" height="400" fill="#f0f0f0"/>
|
|
3
|
-
<text x="400" y="200" font-family="Arial, sans-serif" font-size="32" fill="#999" text-anchor="middle" dominant-baseline="middle">Your Image Here</text>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="400" viewBox="0 0 800 400">
|
|
2
|
+
<rect width="800" height="400" fill="#f0f0f0"/>
|
|
3
|
+
<text x="400" y="200" font-family="Arial, sans-serif" font-size="32" fill="#999" text-anchor="middle" dominant-baseline="middle">Your Image Here</text>
|
|
4
4
|
</svg>
|