@lexho111/plainblog 0.3.5 → 0.3.7

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
@@ -125,7 +125,7 @@ export default class Blog {
125
125
  this.styles += style;
126
126
  }
127
127
 
128
- set assets(files) {
128
+ set stylesheetPath(files) {
129
129
  this.assetFiles = files;
130
130
  }
131
131
 
@@ -201,6 +201,10 @@ export default class Blog {
201
201
  const dbTitle = await this.#databaseModel.getBlogTitle();
202
202
  const dbArticles = await this.#databaseModel.findAll();
203
203
  //console.log(`articles: ${JSON.stringify(dbarticles)}`)
204
+ if(dbArticles.length == 0) {
205
+ dbArticles.push(new Article("Sample Entry #1", "Prow scuttle parrel provost Sail ho shrouds spirits boom mizzenmast yardarm. Pinnace holystone mizzenmast quarter crow's nest nipperkin grog yardarm hempen halter furl. Swab barque interloper chantey doubloon starboard grog black jack gangway rutters.", new Date()));
206
+ dbArticles.push(new Article("Sample Entry #2", "Deadlights jack lad schooner scallywag dance the hempen jig carouser broadside cable strike colors. Bring a spring upon her cable holystone blow the man down spanker Shiver me timbers to go on account lookout wherry doubloon chase. Belay yo-ho-ho keelhaul squiffy black spot yardarm spyglass sheet transom heave to.", new Date()));
207
+ }
204
208
  this.reloadScriptsStylesOnGET = false;
205
209
  if(this.reloadScriptsStylesOnGET) console.log("reload scripts and styles on GET-Request");
206
210
  let title = "";
@@ -233,6 +237,11 @@ export default class Blog {
233
237
  if (this.#isExternalAPI) await postData(this.#apiUrl, newArticleData);
234
238
  // Add the article to the local list for immediate display
235
239
  this.articles.unshift(new Article(title, content, new Date()));
240
+ // remove sample entries
241
+ this.articles = this.articles.filter(
242
+ (art) =>
243
+ art.title !== "Sample Entry #1" && art.title !== "Sample Entry #2"
244
+ );
236
245
  } catch (error) {
237
246
  console.error("Failed to post new article to API:", error);
238
247
  }
@@ -478,10 +487,13 @@ export default class Blog {
478
487
  * @param {string[]} files - Array of file paths to process.
479
488
  */
480
489
  async processAssets(files) {
490
+ // Normalize input to array (handles string or array)
491
+ const fileList = Array.isArray(files) ? files : [files];
492
+
481
493
  const __filename = fileURLToPath(import.meta.url);
482
494
  const __dirname = path.dirname(__filename);
483
- const styleFiles = files.filter(
484
- (f) => (f.endsWith(".scss") || f.endsWith(".css")) && !f.endsWith(".min.css")
495
+ const styleFiles = fileList.filter(
496
+ (f) => typeof f === "string" && (f.endsWith(".scss") || f.endsWith(".css")) && !f.endsWith(".min.css")
485
497
  );
486
498
  //const scriptFiles = files.filter((f) => f.endsWith(".js") && !f.endsWith(".min.js"));
487
499
 
package/README.md CHANGED
@@ -63,7 +63,7 @@ const blog = new Blog();
63
63
  blog.title = "My Blog";
64
64
  blog.style = "body { font-family: Arial, sans-serif; } h1 { color: #333; }";
65
65
  blog.password = "mypassword";
66
- blog.assets = ["my-assets/styles.scss","my-assets/scripts123.js"];
66
+ blog.stylesheetPath = "my-assets/styles.scss";
67
67
 
68
68
  blog.startServer(8080);
69
69
  ```
package/blog.db CHANGED
Binary file
package/blog.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "title": "",
3
+ "articles": [
4
+ {
5
+ "title": "hello",
6
+ "content": "hello world!"
7
+ }
8
+ ]
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexho111/plainblog",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
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}h1{color:#7f0000}nav a{color:#3b40c1;font-size:20px;text-decoration:underline}nav a:visited{color:#3b40c1;text-decoration-color:#3b40c1}
2
- /* source-hash: 91ab1d754238759404d2b8becfe52372f6f7b9c0f136b8b125c69faadeacd9d7 */
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}h1{color:blue}nav a{color:#3b40c1;font-size:20px;text-decoration:underline}nav a:visited{color:#3b40c1;text-decoration-color:#3b40c1}
2
+ /* source-hash: 2883123eb5327954a734dbf32eae2082e8448c15170daa28704ce7b8882036d5 */
Binary file
Binary file
Binary file
@@ -1 +0,0 @@
1
- function test(){console.log("123")}
@@ -1,2 +0,0 @@
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}.grid article h1{color:red}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
- /*# sourceMappingURL=styles.min.css.map */
@@ -1 +0,0 @@
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,CACA,iBACA,SACA,CAOA,cACA,aAAA,CACA,6BACA,CCzBA,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.grid article h1 {\n color: red;\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"]}