@lexho111/plainblog 0.3.4 → 0.3.5

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
@@ -509,7 +509,7 @@ export default class Blog {
509
509
  this.#stylesHash = currentHash;
510
510
 
511
511
  // Compile styles using the standalone script
512
- this.compiledStyles = await compileStyles();
512
+ this.compiledStyles = await compileStyles(fileData);
513
513
 
514
514
  await fs.promises.writeFile(
515
515
  path.join(__dirname, "styles.min.css"),
package/blog.db CHANGED
Binary file
package/build-styles.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { promises as fs } from "fs";
2
2
  import path from "path";
3
+ import { pathToFileURL } from "url";
3
4
  import * as sass from "sass";
4
5
  import postcss from "postcss";
5
6
  import autoprefixer from "autoprefixer";
@@ -20,28 +21,47 @@ async function getFiles(dir) {
20
21
  return Array.prototype.concat(...files);
21
22
  }
22
23
 
23
- export async function compileStyles() {
24
+ export async function compileStyles(fileData) {
24
25
  try {
25
- const allFiles = await getFiles(srcDir);
26
+ let combinedCss = "";
26
27
 
27
- // Filter for .scss files and exclude partials (files starting with _)
28
- // Sort them to ensure consistent concatenation order
29
- const scssFiles = allFiles
30
- .filter((f) => f.endsWith(".scss") && !path.basename(f).startsWith("_"))
31
- .sort();
28
+ if (fileData) {
29
+ const scssFiles = fileData.filter(
30
+ (f) =>
31
+ f.path.endsWith(".scss") && !path.basename(f.path).startsWith("_")
32
+ );
32
33
 
33
- let combinedCss = "";
34
+ for (const file of scssFiles) {
35
+ try {
36
+ const result = sass.compileString(file.content.toString(), {
37
+ loadPaths: [srcDir],
38
+ style: "expanded",
39
+ url: pathToFileURL(file.path),
40
+ });
41
+ combinedCss += result.css + "\n";
42
+ } catch (err) {
43
+ console.error(
44
+ `Error compiling ${path.basename(file.path)}:`,
45
+ err.message
46
+ );
47
+ }
48
+ }
49
+ } else {
50
+ const allFiles = await getFiles(srcDir);
51
+ const scssFiles = allFiles
52
+ .filter((f) => f.endsWith(".scss") && !path.basename(f).startsWith("_"))
53
+ .sort();
34
54
 
35
- // 1. Compile Sass
36
- for (const file of scssFiles) {
37
- try {
38
- const result = sass.compile(file, {
39
- loadPaths: [srcDir],
40
- style: "expanded",
41
- });
42
- combinedCss += result.css + "\n";
43
- } catch (err) {
44
- console.error(`Error compiling ${path.basename(file)}:`, err.message);
55
+ for (const file of scssFiles) {
56
+ try {
57
+ const result = sass.compile(file, {
58
+ loadPaths: [srcDir],
59
+ style: "expanded",
60
+ });
61
+ combinedCss += result.css + "\n";
62
+ } catch (err) {
63
+ console.error(`Error compiling ${path.basename(file)}:`, err.message);
64
+ }
45
65
  }
46
66
  }
47
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexho111/plainblog",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "A tool for creating and serving a minimalist, single-page blog.",
5
5
  "main": "index.js",
6
6
  "type": "module",
Binary file