@lexho111/plainblog 0.4.1 → 0.4.2
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 +2 -2
- package/build-styles.js +18 -0
- package/package.json +1 -1
package/Blog.js
CHANGED
|
@@ -13,7 +13,7 @@ import path from "path";
|
|
|
13
13
|
import { fileURLToPath } from "url";
|
|
14
14
|
import { exec } from "child_process";
|
|
15
15
|
import { promisify } from "util";
|
|
16
|
-
import { compileStyles } from "./build-styles.js";
|
|
16
|
+
import { compileStyles, mergeStyles } from "./build-styles.js";
|
|
17
17
|
|
|
18
18
|
const execPromise = promisify(exec);
|
|
19
19
|
|
|
@@ -536,7 +536,7 @@ export default class Blog {
|
|
|
536
536
|
|
|
537
537
|
this.loadScripts();
|
|
538
538
|
|
|
539
|
-
const finalStyles = this.styles
|
|
539
|
+
const finalStyles = await mergeStyles(this.styles, this.compiledStyles);
|
|
540
540
|
const html = formatHTML(data, this.scripts, finalStyles);
|
|
541
541
|
if (validate(html)) return html;
|
|
542
542
|
throw new Error("Error. Invalid HTML!");
|
package/build-styles.js
CHANGED
|
@@ -51,3 +51,21 @@ export async function compileStyles(fileData) {
|
|
|
51
51
|
return "";
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
export async function mergeStyles(...cssContents) {
|
|
56
|
+
try {
|
|
57
|
+
const combinedCss = cssContents.join("\n");
|
|
58
|
+
|
|
59
|
+
if (combinedCss) {
|
|
60
|
+
const plugins = [autoprefixer(), cssnano()];
|
|
61
|
+
const result = await postcss(plugins).process(combinedCss, {
|
|
62
|
+
from: undefined,
|
|
63
|
+
});
|
|
64
|
+
return result.css;
|
|
65
|
+
}
|
|
66
|
+
return "";
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error("Merge failed:", error);
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
71
|
+
}
|