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/lib/tag/index.js CHANGED
@@ -1,69 +1,70 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- const PageBase = require("../mod/page_base");
5
- const TagPage = require("./tag");
6
-
7
- module.exports = class TagList extends PageBase {
8
- constructor(config) {
9
- super(config);
10
- }
11
-
12
- gatherTags(posts) {
13
- const tags = new Map();
14
- posts.forEach((post) => {
15
- post.tags.forEach((tag) => {
16
- if (!tags.has(tag)) {
17
- tags.set(tag, []);
18
- }
19
- tags.get(tag).push({
20
- path: post.path,
21
- title: post.title,
22
- date: post.date,
23
- description: post.description,
24
- });
25
- });
26
- });
27
-
28
- return tags;
29
- }
30
-
31
- generateContent(articles) {
32
- const tagMap = this.gatherTags(articles);
33
-
34
- let tagArray = [];
35
- for (let [tag, posts] of tagMap) {
36
- tagArray.push({
37
- name: tag,
38
- path: tag.replace(/\s+/g, "_"),
39
- count: posts.length,
40
- });
41
- }
42
-
43
- tagArray.sort((a, b) => a.name.localeCompare(b.name));
44
-
45
- if (!fs.existsSync(`${this.config.dev.outdir}/tags/`))
46
- fs.mkdirSync(`${this.config.dev.outdir}/tags/`);
47
-
48
- this.imageURL = this.config.image;
49
- this.description = "Tag List";
50
- const data = { tags: tagArray, pageTitle: "All tags" };
51
- this.url = `${this.config.blogsite}/tag_list.html`;
52
- this.title = `${this.config.blogName}: ${data.pageTitle}`;
53
-
54
- const templatePath = path.join(this.config.themePath, "layouts", "tag_list.html");
55
- fs.writeFile(
56
- `${this.config.dev.outdir}/tags/index.html`,
57
- this.generateHTML(templatePath, data),
58
- (e) => {
59
- if (e) throw e;
60
- console.log(`tags/index.html for tags was created successfully`);
61
- },
62
- );
63
-
64
- const tagPage = new TagPage(this.config);
65
- for (let [tag, posts] of tagMap) {
66
- tagPage.createPages(tag, posts);
67
- }
68
- }
69
- };
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const PageBase = require("../mod/page_base");
5
+ const TagPage = require("./tag");
6
+
7
+ module.exports = class TagList extends PageBase {
8
+ constructor(config) {
9
+ super(config);
10
+ }
11
+
12
+ gatherTags(posts) {
13
+ const tags = new Map();
14
+ posts.forEach((post) => {
15
+ post.tags.forEach((tag) => {
16
+ if (!tags.has(tag)) {
17
+ tags.set(tag, []);
18
+ }
19
+ tags.get(tag).push({
20
+ path: post.path,
21
+ title: post.title,
22
+ date: post.date,
23
+ description: post.description,
24
+ });
25
+ });
26
+ });
27
+
28
+ return tags;
29
+ }
30
+
31
+ generateContent(articles) {
32
+ const tagMap = this.gatherTags(articles);
33
+
34
+ let tagArray = [];
35
+ for (let [tag, posts] of tagMap) {
36
+ tagArray.push({
37
+ name: tag,
38
+ path: tag.replace(/\s+/g, "_"),
39
+ count: posts.length,
40
+ });
41
+ }
42
+
43
+ tagArray.sort((a, b) => a.name.localeCompare(b.name));
44
+
45
+ const tagsDir = path.join(this.config.dev.outdir, "tags");
46
+ if (!fs.existsSync(tagsDir))
47
+ fs.mkdirSync(tagsDir);
48
+
49
+ this.imageURL = this.config.image;
50
+ this.description = "Tag List";
51
+ const data = { tags: tagArray, pageTitle: "All tags" };
52
+ this.url = `${this.config.blogsite}/tag_list.html`;
53
+ this.title = `${this.config.blogName}: ${data.pageTitle}`;
54
+
55
+ const templatePath = path.join(this.config.themePath, "layouts", "tag_list.html");
56
+ fs.writeFile(
57
+ path.join(tagsDir, "index.html"),
58
+ this.generateHTML(templatePath, data),
59
+ (e) => {
60
+ if (e) throw e;
61
+ console.log(`tags/index.html for tags was created successfully`);
62
+ },
63
+ );
64
+
65
+ const tagPage = new TagPage(this.config);
66
+ for (let [tag, posts] of tagMap) {
67
+ tagPage.createPages(tag, posts);
68
+ }
69
+ }
70
+ };
package/lib/tag/tag.js CHANGED
@@ -1,29 +1,30 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const PageBase = require("../mod/page_base");
4
-
5
- module.exports = class TagPage extends PageBase {
6
- createPages(tag, posts) {
7
- let tagPath = tag.replace(/\s+/g, "_"); // Replace spaces with underscores
8
- if (!fs.existsSync(`${this.config.dev.outdir}/tags/${tagPath}`))
9
- fs.mkdirSync(`${this.config.dev.outdir}/tags/${tagPath}`);
10
-
11
- // FIXME: imageURL should refer to the image related to the tag
12
- this.imageURL = this.config.image;
13
-
14
- const data = { tag: tag, posts: posts, url: "tags/" + tagPath };
15
- this.url = `${this.config.blogsite}/${data.url}`;
16
- this.title = `${this.config.blogName}: Entries tagged - ${data.tag}`;
17
- this.description = `List up all posts including '${data.tag}' tag.`;
18
-
19
- const templatePath = path.join(this.config.themePath, "layouts", "tag.html");
20
- fs.writeFile(
21
- `${this.config.dev.outdir}/tags/${tagPath}/index.html`,
22
- this.generateHTML(templatePath, data),
23
- (e) => {
24
- if (e) throw e;
25
- console.log(`/tags/${tagPath}/index.html was created successfully`);
26
- },
27
- );
28
- }
29
- };
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const PageBase = require("../mod/page_base");
4
+
5
+ module.exports = class TagPage extends PageBase {
6
+ createPages(tag, posts) {
7
+ let tagPath = tag.replace(/\s+/g, "_"); // Replace spaces with underscores
8
+ const tagDir = path.join(this.config.dev.outdir, "tags", tagPath);
9
+ if (!fs.existsSync(tagDir))
10
+ fs.mkdirSync(tagDir);
11
+
12
+ // FIXME: imageURL should refer to the image related to the tag
13
+ this.imageURL = this.config.image;
14
+
15
+ const data = { tag: tag, posts: posts, url: "tags/" + tagPath };
16
+ this.url = `${this.config.blogsite}/${data.url}`;
17
+ this.title = `${this.config.blogName}: Entries tagged - ${data.tag}`;
18
+ this.description = `List up all posts including '${data.tag}' tag.`;
19
+
20
+ const templatePath = path.join(this.config.themePath, "layouts", "tag.html");
21
+ fs.writeFile(
22
+ path.join(tagDir, "index.html"),
23
+ this.generateHTML(templatePath, data),
24
+ (e) => {
25
+ if (e) throw e;
26
+ console.log(`/tags/${tagPath}/index.html was created successfully`);
27
+ },
28
+ );
29
+ }
30
+ };
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "fossbook",
3
- "version": "0.0.4",
4
- "description": "A lightweight static blog site generator for GitHub Pages",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "build": "node bin/fossbook.js build",
8
- "start": "node bin/fossbook.js serve",
9
- "test": "mocha test",
10
- "prettier": "prettier --write ."
11
- },
12
- "keywords": [
13
- "static-site-generator",
14
- "blog",
15
- "github-pages",
16
- "markdown"
17
- ],
18
- "author": "Joone Hur",
19
- "license": "BSD-3-Clause",
20
- "dependencies": {
21
- "express": "^4.19.1",
22
- "front-matter": "^4.0.2",
23
- "highlight.js": "^11.9.0",
24
- "marked": "^12.0.1"
25
- },
26
- "devDependencies": {
27
- "mocha": "^10.2.0",
28
- "prettier": "^3.2.5"
29
- },
30
- "bin": {
31
- "fossbook": "bin/fossbook.js"
32
- },
33
- "engines": {
34
- "node": ">=18"
35
- },
36
- "files": [
37
- "bin/",
38
- "lib/",
39
- "themes/"
40
- ],
41
- "repository": {
42
- "type": "git",
43
- "url": "https://github.com/joone/fossbook"
44
- }
45
- }
1
+ {
2
+ "name": "fossbook",
3
+ "version": "0.0.6",
4
+ "description": "A lightweight static blog site generator for GitHub Pages",
5
+ "main": "lib/index.js",
6
+ "scripts": {
7
+ "build": "node bin/fossbook.js build",
8
+ "start": "node bin/fossbook.js serve",
9
+ "test": "mocha test",
10
+ "prettier": "prettier --write ."
11
+ },
12
+ "keywords": [
13
+ "static-site-generator",
14
+ "blog",
15
+ "github-pages",
16
+ "markdown"
17
+ ],
18
+ "author": "Joone Hur",
19
+ "license": "BSD-3-Clause",
20
+ "dependencies": {
21
+ "express": "^4.19.1",
22
+ "front-matter": "^4.0.2",
23
+ "highlight.js": "^11.9.0",
24
+ "marked": "^12.0.1"
25
+ },
26
+ "devDependencies": {
27
+ "mocha": "^10.2.0",
28
+ "prettier": "^3.2.5"
29
+ },
30
+ "bin": {
31
+ "fossbook": "bin/fossbook.js"
32
+ },
33
+ "engines": {
34
+ "node": ">=18"
35
+ },
36
+ "files": [
37
+ "bin/",
38
+ "lib/",
39
+ "themes/"
40
+ ],
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/joone/fossbook"
44
+ }
45
+ }