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/lib/index.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
4
|
-
const Page = require("./mod/page");
|
|
5
|
-
const HomePagination = require("./home");
|
|
6
|
-
const AllPostsPage = require("./all_posts");
|
|
7
|
-
const Posts = require("./posts");
|
|
8
|
-
const TagPages = require("./tag");
|
|
9
|
-
|
|
10
|
-
function copyDirectoryRecursive(src, dest) {
|
|
11
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
12
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
13
|
-
|
|
14
|
-
for (const entry of entries) {
|
|
15
|
-
const srcPath = path.join(src, entry.name);
|
|
16
|
-
const destPath = path.join(dest, entry.name);
|
|
17
|
-
|
|
18
|
-
if (entry.isDirectory()) {
|
|
19
|
-
copyDirectoryRecursive(srcPath, destPath);
|
|
20
|
-
} else {
|
|
21
|
-
fs.copyFileSync(srcPath, destPath);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function build(config) {
|
|
27
|
-
// Remove the output directory
|
|
28
|
-
if (fs.existsSync(config.dev.outdir))
|
|
29
|
-
fs.rmSync(config.dev.outdir, { recursive: true });
|
|
30
|
-
fs.mkdirSync(config.dev.outdir);
|
|
31
|
-
|
|
32
|
-
// Create post pages in output directory
|
|
33
|
-
const posts = new Posts(config);
|
|
34
|
-
const postObjects = posts.createPostObjects();
|
|
35
|
-
|
|
36
|
-
postObjects.forEach((post) => {
|
|
37
|
-
post.generateContent("post.html");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Create home page and pagination in output/page directory
|
|
41
|
-
const homePagination = new HomePagination(config);
|
|
42
|
-
homePagination.generateContent(postObjects);
|
|
43
|
-
|
|
44
|
-
// Create all posts page in output/all_posts directory
|
|
45
|
-
const allPostsPage = new AllPostsPage(config);
|
|
46
|
-
allPostsPage.generateContent(postObjects);
|
|
47
|
-
|
|
48
|
-
// Create tag pages in output/tags directory
|
|
49
|
-
const tagPages = new TagPages(config);
|
|
50
|
-
tagPages.generateContent(postObjects);
|
|
51
|
-
|
|
52
|
-
// Create about page in output/about directory
|
|
53
|
-
const aboutPath = config.dev.about;
|
|
54
|
-
if (fs.existsSync(aboutPath)) {
|
|
55
|
-
const aboutPage = new Page(config);
|
|
56
|
-
aboutPage.readSource(aboutPath);
|
|
57
|
-
aboutPage.generateContent("page.html", "about");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Copy static directory to output directory
|
|
61
|
-
const staticImagesDir = path.join(config.dev.staticDir, "images");
|
|
62
|
-
if (fs.existsSync(staticImagesDir)) {
|
|
63
|
-
copyDirectoryRecursive(staticImagesDir, path.join(config.dev.outdir, "images"));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Copy theme assets to output directory
|
|
67
|
-
const themeAssetsDir = path.join(config.themePath, "assets");
|
|
68
|
-
if (fs.existsSync(themeAssetsDir)) {
|
|
69
|
-
copyDirectoryRecursive(themeAssetsDir, config.dev.outdir);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Create CNAME file for GitHub Pages
|
|
73
|
-
if (config.githubCNAME)
|
|
74
|
-
fs.writeFileSync(path.join(config.dev.outdir, "CNAME"), config.githubCNAME);
|
|
75
|
-
|
|
76
|
-
console.log("Build completed successfully");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
module.exports = { build };
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const Page = require("./mod/page");
|
|
5
|
+
const HomePagination = require("./home");
|
|
6
|
+
const AllPostsPage = require("./all_posts");
|
|
7
|
+
const Posts = require("./posts");
|
|
8
|
+
const TagPages = require("./tag");
|
|
9
|
+
|
|
10
|
+
function copyDirectoryRecursive(src, dest) {
|
|
11
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
12
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
13
|
+
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
const srcPath = path.join(src, entry.name);
|
|
16
|
+
const destPath = path.join(dest, entry.name);
|
|
17
|
+
|
|
18
|
+
if (entry.isDirectory()) {
|
|
19
|
+
copyDirectoryRecursive(srcPath, destPath);
|
|
20
|
+
} else {
|
|
21
|
+
fs.copyFileSync(srcPath, destPath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function build(config) {
|
|
27
|
+
// Remove the output directory
|
|
28
|
+
if (fs.existsSync(config.dev.outdir))
|
|
29
|
+
fs.rmSync(config.dev.outdir, { recursive: true });
|
|
30
|
+
fs.mkdirSync(config.dev.outdir);
|
|
31
|
+
|
|
32
|
+
// Create post pages in output directory
|
|
33
|
+
const posts = new Posts(config);
|
|
34
|
+
const postObjects = posts.createPostObjects();
|
|
35
|
+
|
|
36
|
+
postObjects.forEach((post) => {
|
|
37
|
+
post.generateContent("post.html");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Create home page and pagination in output/page directory
|
|
41
|
+
const homePagination = new HomePagination(config);
|
|
42
|
+
homePagination.generateContent(postObjects);
|
|
43
|
+
|
|
44
|
+
// Create all posts page in output/all_posts directory
|
|
45
|
+
const allPostsPage = new AllPostsPage(config);
|
|
46
|
+
allPostsPage.generateContent(postObjects);
|
|
47
|
+
|
|
48
|
+
// Create tag pages in output/tags directory
|
|
49
|
+
const tagPages = new TagPages(config);
|
|
50
|
+
tagPages.generateContent(postObjects);
|
|
51
|
+
|
|
52
|
+
// Create about page in output/about directory
|
|
53
|
+
const aboutPath = config.dev.about;
|
|
54
|
+
if (fs.existsSync(aboutPath)) {
|
|
55
|
+
const aboutPage = new Page(config);
|
|
56
|
+
aboutPage.readSource(aboutPath);
|
|
57
|
+
aboutPage.generateContent("page.html", "about");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Copy static directory to output directory
|
|
61
|
+
const staticImagesDir = path.join(config.dev.staticDir, "images");
|
|
62
|
+
if (fs.existsSync(staticImagesDir)) {
|
|
63
|
+
copyDirectoryRecursive(staticImagesDir, path.join(config.dev.outdir, "images"));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Copy theme assets to output directory
|
|
67
|
+
const themeAssetsDir = path.join(config.themePath, "assets");
|
|
68
|
+
if (fs.existsSync(themeAssetsDir)) {
|
|
69
|
+
copyDirectoryRecursive(themeAssetsDir, config.dev.outdir);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Create CNAME file for GitHub Pages
|
|
73
|
+
if (config.githubCNAME)
|
|
74
|
+
fs.writeFileSync(path.join(config.dev.outdir, "CNAME"), config.githubCNAME);
|
|
75
|
+
|
|
76
|
+
console.log("Build completed successfully");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = { build };
|