@lexho111/plainblog 0.2.4 → 0.2.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/Blog.js CHANGED
@@ -147,7 +147,7 @@ export default class Blog {
147
147
  const dbTitle = await this.#databaseModel.getBlogTitle();
148
148
  const dbArticles = await this.#databaseModel.findAll();
149
149
  //console.log(`articles: ${JSON.stringify(dbarticles)}`)
150
- this.reloadScriptsStylesOnGET = false;
150
+ this.reloadScriptsStylesOnGET = true;
151
151
  if(this.reloadScriptsStylesOnGET) console.log("reload scripts and styles on GET-Request");
152
152
  let title = "";
153
153
  if (this.title.length > 0) title = this.title; // use blog title if set
@@ -188,7 +188,7 @@ export default class Blog {
188
188
  if (this.#databaseModel) await this.#databaseModel.save(newArticleData);
189
189
  if (this.#isExternalAPI) await postData(this.#apiUrl, newArticleData);
190
190
  // Add the article to the local list for immediate display
191
- this.articles.unshift(new Article(title, content));
191
+ this.articles.unshift(new Article(title, content, new Date()));
192
192
  } catch (error) {
193
193
  console.error("Failed to post new article to API:", error);
194
194
  }
@@ -387,7 +387,7 @@ export default class Blog {
387
387
  articles: this.articles,
388
388
  };
389
389
  const markdown = formatMarkdown(data);
390
- return markdown;
390
+ console.log(markdown);
391
391
  }
392
392
 
393
393
  /** render this blog content to valid html */
@@ -100,7 +100,8 @@ export default class DatabaseModel {
100
100
  limit,
101
101
  offset,
102
102
  };
103
- return this.#Article.findAll(options);
103
+ const articles = await this.#Article.findAll(options);
104
+ return articles.map((article) => article.get({ plain: true }));
104
105
  }
105
106
 
106
107
  async save(newArticle) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexho111/plainblog",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "A tool for creating and serving a minimalist, single-page blog.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/styles.min.css CHANGED
@@ -1,2 +1,2 @@
1
- .grid{border:0 solid #000;display:grid;gap:.25rem;grid-template-columns:1fr}.grid article{border:0 solid #ccc;border-radius:4px;min-width:0;overflow-wrap:break-word;padding:.25rem}nav a:visited{color:#3b40c1;text-decoration-color:#3b40c1}body{background-color:#fdfdfd;font-family:Arial}nav a{color:#3b40c1;font-size:20px;text-decoration:underline}.datetime{color:#434343;font-style:italic}
1
+ .grid{border:0 solid #000;display:grid;gap:.25rem;grid-template-columns:1fr}.grid article{border:0 solid #ccc;border-radius:4px;min-width:0;overflow-wrap:break-word;padding:.25rem}nav a:visited{color:#3b40c1;text-decoration-color:#3b40c1}body{background-color:#fdfdfd;font-family:Arial}nav a{color:#3b40c1;font-size:20px;text-decoration:underline}.datetime{color:#434343;font-style:italic}h2{margin:0 0 5px}p{margin-top:10px}span{margin:0}
2
2
  /*# sourceMappingURL=styles.min.css.map */
@@ -1 +1 @@
1
- {"version":3,"sources":["styles-compiled.css","styles.css"],"names":[],"mappings":"AAAA,MAIA,mBAAA,CAHA,YAAA,CAEA,UAAA,CADA,yBAGA,CACA,cAEA,mBAAA,CACA,iBAAA,CACA,WAAA,CACA,wBAAA,CAJA,cAKA,CAOA,cACA,aAAA,CACA,6BACA,CCtBA,KACA,wBAAA,CACA,iBACA,CAEA,MAEA,aAAA,CACA,cAAA,CAFA,yBAGA,CAEA,UAEA,aAAA,CADA,iBAEA","file":"styles.min.css","sourcesContent":[".grid {\n display: grid;\n grid-template-columns: 1fr;\n gap: 0.25rem;\n border: 0px solid black;\n}\n.grid article {\n padding: 0.25rem;\n border: 0px solid #ccc;\n border-radius: 4px;\n min-width: 0; /* Allow grid items to shrink */\n overflow-wrap: break-word; /* Break long words */\n}\n\nnav a {\n text-decoration: underline;\n color: rgb(59, 64, 193);\n font-size: 20px;\n}\nnav a:visited {\n color: rgb(59, 64, 193);\n text-decoration-color: rgb(59, 64, 193);\n}","body {\n background-color: rgb(253, 253, 253);\n font-family: Arial;\n}\n\nnav a {\n text-decoration: underline;\n color: rgb(59, 64, 193);\n font-size: 20px;\n}\n\n.datetime {\n font-style: italic;\n color: rgb(67, 67, 67);\n}\n"]}
1
+ {"version":3,"sources":["styles-compiled.css","styles.css"],"names":[],"mappings":"AAAA,MAIA,mBAAA,CAHA,YAAA,CAEA,UAAA,CADA,yBAGA,CACA,cAEA,mBAAA,CACA,iBAAA,CACA,WAAA,CACA,wBAAA,CAJA,cAKA,CAOA,cACA,aAAA,CACA,6BACA,CCtBA,KACA,wBAAA,CACA,iBACA,CAEA,MAEA,aAAA,CACA,cAAA,CAFA,yBAGA,CAEA,UAEA,aAAA,CADA,iBAEA,CAEA,GAEA,cACA,CAEA,EACA,eACA,CAEA,KACA,QACA","file":"styles.min.css","sourcesContent":[".grid {\n display: grid;\n grid-template-columns: 1fr;\n gap: 0.25rem;\n border: 0px solid black;\n}\n.grid article {\n padding: 0.25rem;\n border: 0px solid #ccc;\n border-radius: 4px;\n min-width: 0; /* Allow grid items to shrink */\n overflow-wrap: break-word; /* Break long words */\n}\n\nnav a {\n text-decoration: underline;\n color: rgb(59, 64, 193);\n font-size: 20px;\n}\nnav a:visited {\n color: rgb(59, 64, 193);\n text-decoration-color: rgb(59, 64, 193);\n}","body {\n background-color: rgb(253, 253, 253);\n font-family: Arial;\n}\n\nnav a {\n text-decoration: underline;\n color: rgb(59, 64, 193);\n font-size: 20px;\n}\n\n.datetime {\n font-style: italic;\n color: rgb(67, 67, 67);\n}\n\nh2 {\n margin: 0;\n margin-bottom: 5px;\n}\n\np {\n margin-top: 10px;\n}\n\nspan {\n margin: 0;\n}\n"]}
package/test/blog.test.js CHANGED
@@ -71,11 +71,12 @@ describe("test blog", () => {
71
71
  const consoleSpy = jest.spyOn(console, "log").mockImplementation(() => {});
72
72
 
73
73
  // Act: Call the method we want to test
74
- await myblog.print();
74
+ myblog.print();
75
+ await new Promise((resolve) => setTimeout(resolve, 100));
75
76
 
76
77
  // Assert: Check if console.log was called with the correct strings
77
78
  expect(consoleSpy).toHaveBeenCalled();
78
- const output = consoleSpy.mock.calls[0][0];
79
+ const output = consoleSpy.mock.calls.map((call) => call[0]).join("\n");
79
80
  expect(output).toContain("# My Test Blog");
80
81
  expect(output).toContain("## Article 1");
81
82
  expect(output).toContain("Content 1");