@lexho111/plainblog 0.5.13 → 0.5.15

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
@@ -9,6 +9,7 @@ import { formatHTML, header, formatMarkdown, validate } from "./Formatter.js"; /
9
9
  import path from "path";
10
10
  import { fileURLToPath } from "url";
11
11
  import { compileStyles, mergeStyles } from "./build-styles.js";
12
+ import pkg from "./package.json" with { type: "json" };
12
13
 
13
14
  export default class Blog {
14
15
  constructor() {
@@ -30,7 +31,7 @@ export default class Blog {
30
31
  this.reloadStylesOnGET = false;
31
32
  this.sessions = new Set();
32
33
 
33
- this.#version = "0.0.1"; //pkg.version;
34
+ this.#version = pkg.version;
34
35
  console.log(`version: ${this.#version}`);
35
36
  }
36
37
 
@@ -72,6 +73,7 @@ export default class Blog {
72
73
  #stylesHash = "";
73
74
  //#scriptsHash = "";
74
75
  #stylesheetPath = "";
76
+ compilestyle = false;
75
77
 
76
78
  setTitle(title) {
77
79
  this.#title = title;
@@ -81,8 +83,13 @@ export default class Blog {
81
83
  this.#password = password;
82
84
  }
83
85
 
86
+ /**
87
+ * Appends CSS rules to the \<style\>-tag.
88
+ * @param {string} style - A string containing CSS rules.
89
+ */
84
90
  setStyle(style) {
85
91
  this.#styles += style;
92
+ this.compilestyle = true;
86
93
  }
87
94
 
88
95
  set title(t) {
@@ -120,6 +127,7 @@ export default class Blog {
120
127
  */
121
128
  set style(style) {
122
129
  this.#styles += style;
130
+ this.compilestyle = true;
123
131
  }
124
132
 
125
133
  /**
@@ -129,6 +137,7 @@ export default class Blog {
129
137
  set stylesheetPath(files) {
130
138
  this.#stylesheetPath = files;
131
139
  console.log(`this.#stylesheetPath: ${this.#stylesheetPath}`);
140
+ this.compilestyle = true;
132
141
  }
133
142
 
134
143
  addArticle(article) {
@@ -233,7 +242,7 @@ export default class Blog {
233
242
  .update(combinedStyles)
234
243
  .digest("hex");
235
244
 
236
- if (srcHash !== publicHash) {
245
+ if (srcHash !== publicHash && this.compilestyle) {
237
246
  console.log("Styles have changed. Recompiling...");
238
247
  const finalStyles = await mergeStyles(this.#styles, srcStyles);
239
248
  try {
@@ -632,7 +641,7 @@ export default class Blog {
632
641
  .digest("hex");
633
642
 
634
643
  // check if hash matches
635
- if (currentHash !== this.#stylesHash) {
644
+ if (currentHash !== this.#stylesHash && this.compilestyle) {
636
645
  console.log("Style assets have changed. Recompiling...");
637
646
  this.#stylesHash = currentHash;
638
647
 
package/build-styles.js CHANGED
@@ -43,10 +43,7 @@ async function postcss2(css) {
43
43
  autoprefixer = (await import("autoprefixer")).default;
44
44
  cssnano = (await import("cssnano")).default;
45
45
  } catch (error) {
46
- console.error(
47
- "\n\x1b[31m%s\x1b[0m",
48
- "ERROR: Missing CSS processing dependencies."
49
- );
46
+ console.error("Missing CSS processing dependencies.");
50
47
  console.error(
51
48
  "To use this feature, please install the following packages manually:"
52
49
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexho111/plainblog",
3
- "version": "0.5.13",
3
+ "version": "0.5.15",
4
4
  "description": "A tool for creating and serving a minimalist, single-page blog.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- body{background-color:#fdfdfd;font-family:Arial}nav a{color:#3b40c1;font-size:20px;text-decoration:underline}.datetime{color:#434343;font-style:normal}h2{color:#a9a9a9;margin:0 0 5px}p{margin-top:10px}span{margin:0}
2
- /* source-hash: fa9deb7a7f0781f463cd3e8fd3c3ceddec518535b0a6d13af7309ef9a2f76c32 */