defuss-ssg 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  <h1 align="center">
2
2
 
3
- <img src="assets/defuss_mascott.png" width="100px" />
3
+ <img src="https://github.com/kyr0/defuss/blob/main/assets/defuss_mascott.png?raw=true" width="100px" />
4
4
 
5
5
  <p align="center">
6
+
6
7
  <code>defuss-ssg</code>
8
+
7
9
  </p>
8
10
 
9
11
  <sup align="center">
10
12
 
11
- Simple Static Site Generator (SSG) for defuss - with support for Markdown, MDX, and Jinja2 templates
13
+ Static Site Generator (SSG) for defuss
12
14
 
13
15
  </sup>
14
16
 
@@ -18,7 +20,7 @@ Simple Static Site Generator (SSG) for defuss - with support for Markdown, MDX,
18
20
  Usage
19
21
  </h3>
20
22
 
21
- Simply generate a static site from a content directory to an output directory with full `defuss`-MDX (GFM + Frontmatter) support:
23
+ Simply generate a static site from a content directory to an output directory with full defuss-MDX (GFM + Frontmatter) support:
22
24
 
23
25
  ```bash
24
26
  npx defuss-ssg build ./folder
package/dist/cli.cjs CHANGED
@@ -1,15 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var serve = require('./serve-DvB62foO.cjs');
3
+ var serve = require('./serve-KTJqW3m0.cjs');
4
4
  var node_path = require('node:path');
5
+ var node_fs = require('node:fs');
6
+ var node_child_process = require('node:child_process');
5
7
  require('chokidar');
6
8
  require('express');
7
9
  require('serve-static');
8
- require('node:fs');
9
10
  require('esbuild');
10
- require('remark-frontmatter');
11
11
  require('rehype-katex');
12
+ require('rehype-stringify');
13
+ require('remark-frontmatter');
12
14
  require('remark-math');
15
+ require('remark-gfm');
16
+ require('remark-parse');
17
+ require('remark-rehype');
13
18
  require('remark-mdx-frontmatter');
14
19
  require('./tailwind-C4AuHybm.cjs');
15
20
  require('@mdx-js/esbuild');
@@ -17,7 +22,47 @@ require('fast-glob');
17
22
  require('defuss/server');
18
23
  require('node:fs/promises');
19
24
  require('node:url');
20
- require('node:child_process');
25
+
26
+ const setup = async (projectDir) => {
27
+ const projectDirStatus = serve.validateProjectDir(projectDir);
28
+ if (projectDirStatus.code !== "OK") return projectDirStatus;
29
+ const packageJsonPath = node_path.join(projectDir, "package.json");
30
+ if (!node_fs.existsSync(packageJsonPath)) {
31
+ return {
32
+ code: "MISSING_PACKAGE_JSON",
33
+ message: `package.json not found in ${projectDir}`
34
+ };
35
+ }
36
+ let packageJson;
37
+ try {
38
+ packageJson = JSON.parse(node_fs.readFileSync(packageJsonPath, "utf-8"));
39
+ } catch (error) {
40
+ return {
41
+ code: "INVALID_JSON",
42
+ message: `Error reading package.json in ${projectDir}: ${error.message}`
43
+ };
44
+ }
45
+ const packageManager = packageJson.packageManager || "npm";
46
+ const pm = packageManager.split("@")[0];
47
+ const validPMs = ["npm", "yarn", "pnpm", "bun"];
48
+ if (!validPMs.includes(pm)) {
49
+ return {
50
+ code: "UNSUPPORTED_PM",
51
+ message: `Unsupported package manager: ${pm}`
52
+ };
53
+ }
54
+ console.log(`Setting up project in ${projectDir} using ${pm}...`);
55
+ try {
56
+ node_child_process.execSync(`${pm} install`, { cwd: projectDir, stdio: "inherit" });
57
+ console.log("Dependencies installed successfully.");
58
+ } catch (error) {
59
+ return {
60
+ code: "INSTALL_FAILED",
61
+ message: `Failed to install dependencies: ${error.message}`
62
+ };
63
+ }
64
+ return { code: "OK", message: "Setup completed successfully" };
65
+ };
21
66
 
22
67
  (async () => {
23
68
  const args = process.argv.slice(2);
@@ -29,6 +74,7 @@ require('node:child_process');
29
74
  process.exit(1);
30
75
  }
31
76
  const projectDir = node_path.resolve(folder);
77
+ await setup(projectDir);
32
78
  if (command === "build") {
33
79
  console.log(`Building ${folder}...`);
34
80
  await serve.build({
package/dist/cli.mjs CHANGED
@@ -1,14 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import { d as build, s as serve } from './serve-C-BY5Ydk.mjs';
3
- import { resolve } from 'node:path';
2
+ import { v as validateProjectDir, d as build, s as serve } from './serve-CzCDilBA.mjs';
3
+ import { join, resolve } from 'node:path';
4
+ import { existsSync, readFileSync } from 'node:fs';
5
+ import { execSync } from 'node:child_process';
4
6
  import 'chokidar';
5
7
  import 'express';
6
8
  import 'serve-static';
7
- import 'node:fs';
8
9
  import 'esbuild';
9
- import 'remark-frontmatter';
10
10
  import 'rehype-katex';
11
+ import 'rehype-stringify';
12
+ import 'remark-frontmatter';
11
13
  import 'remark-math';
14
+ import 'remark-gfm';
15
+ import 'remark-parse';
16
+ import 'remark-rehype';
12
17
  import 'remark-mdx-frontmatter';
13
18
  import './tailwind-DV23JSh-.mjs';
14
19
  import '@mdx-js/esbuild';
@@ -16,7 +21,47 @@ import 'fast-glob';
16
21
  import 'defuss/server';
17
22
  import 'node:fs/promises';
18
23
  import 'node:url';
19
- import 'node:child_process';
24
+
25
+ const setup = async (projectDir) => {
26
+ const projectDirStatus = validateProjectDir(projectDir);
27
+ if (projectDirStatus.code !== "OK") return projectDirStatus;
28
+ const packageJsonPath = join(projectDir, "package.json");
29
+ if (!existsSync(packageJsonPath)) {
30
+ return {
31
+ code: "MISSING_PACKAGE_JSON",
32
+ message: `package.json not found in ${projectDir}`
33
+ };
34
+ }
35
+ let packageJson;
36
+ try {
37
+ packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
38
+ } catch (error) {
39
+ return {
40
+ code: "INVALID_JSON",
41
+ message: `Error reading package.json in ${projectDir}: ${error.message}`
42
+ };
43
+ }
44
+ const packageManager = packageJson.packageManager || "npm";
45
+ const pm = packageManager.split("@")[0];
46
+ const validPMs = ["npm", "yarn", "pnpm", "bun"];
47
+ if (!validPMs.includes(pm)) {
48
+ return {
49
+ code: "UNSUPPORTED_PM",
50
+ message: `Unsupported package manager: ${pm}`
51
+ };
52
+ }
53
+ console.log(`Setting up project in ${projectDir} using ${pm}...`);
54
+ try {
55
+ execSync(`${pm} install`, { cwd: projectDir, stdio: "inherit" });
56
+ console.log("Dependencies installed successfully.");
57
+ } catch (error) {
58
+ return {
59
+ code: "INSTALL_FAILED",
60
+ message: `Failed to install dependencies: ${error.message}`
61
+ };
62
+ }
63
+ return { code: "OK", message: "Setup completed successfully" };
64
+ };
20
65
 
21
66
  (async () => {
22
67
  const args = process.argv.slice(2);
@@ -28,6 +73,7 @@ import 'node:child_process';
28
73
  process.exit(1);
29
74
  }
30
75
  const projectDir = resolve(folder);
76
+ await setup(projectDir);
31
77
  if (command === "build") {
32
78
  console.log(`Building ${folder}...`);
33
79
  await build({
package/dist/index.cjs CHANGED
@@ -1,15 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var serve = require('./serve-DvB62foO.cjs');
3
+ var serve = require('./serve-KTJqW3m0.cjs');
4
4
  require('chokidar');
5
5
  require('express');
6
6
  require('serve-static');
7
7
  require('node:path');
8
8
  require('node:fs');
9
9
  require('esbuild');
10
- require('remark-frontmatter');
11
10
  require('rehype-katex');
11
+ require('rehype-stringify');
12
+ require('remark-frontmatter');
12
13
  require('remark-math');
14
+ require('remark-gfm');
15
+ require('remark-parse');
16
+ require('remark-rehype');
13
17
  require('remark-mdx-frontmatter');
14
18
  require('./tailwind-C4AuHybm.cjs');
15
19
  require('@mdx-js/esbuild');
@@ -17,7 +21,6 @@ require('fast-glob');
17
21
  require('defuss/server');
18
22
  require('node:fs/promises');
19
23
  require('node:url');
20
- require('node:child_process');
21
24
 
22
25
 
23
26
 
package/dist/index.mjs CHANGED
@@ -1,13 +1,17 @@
1
- export { d as build, c as configDefaults, b as readConfig, a as rehypePlugins, r as remarkPlugins, s as serve } from './serve-C-BY5Ydk.mjs';
1
+ export { d as build, c as configDefaults, b as readConfig, a as rehypePlugins, r as remarkPlugins, s as serve } from './serve-CzCDilBA.mjs';
2
2
  import 'chokidar';
3
3
  import 'express';
4
4
  import 'serve-static';
5
5
  import 'node:path';
6
6
  import 'node:fs';
7
7
  import 'esbuild';
8
- import 'remark-frontmatter';
9
8
  import 'rehype-katex';
9
+ import 'rehype-stringify';
10
+ import 'remark-frontmatter';
10
11
  import 'remark-math';
12
+ import 'remark-gfm';
13
+ import 'remark-parse';
14
+ import 'remark-rehype';
11
15
  import 'remark-mdx-frontmatter';
12
16
  import './tailwind-DV23JSh-.mjs';
13
17
  import '@mdx-js/esbuild';
@@ -15,4 +19,3 @@ import 'fast-glob';
15
19
  import 'defuss/server';
16
20
  import 'node:fs/promises';
17
21
  import 'node:url';
18
- import 'node:child_process';
@@ -2,11 +2,15 @@ import chokidar from 'chokidar';
2
2
  import express from 'express';
3
3
  import serveStatic from 'serve-static';
4
4
  import { join, resolve, dirname, sep } from 'node:path';
5
- import { existsSync, statSync, readFileSync, rmdirSync, mkdirSync } from 'node:fs';
5
+ import { existsSync, statSync, rmdirSync, mkdirSync } from 'node:fs';
6
6
  import esbuild from 'esbuild';
7
- import remarkFrontmatter from 'remark-frontmatter';
8
7
  import rehypeKatex from 'rehype-katex';
8
+ import rehypeStringify from 'rehype-stringify';
9
+ import remarkFrontmatter from 'remark-frontmatter';
9
10
  import remarkMath from 'remark-math';
11
+ import remarkGfm from 'remark-gfm';
12
+ import remarkParse from 'remark-parse';
13
+ import remarkRehype from 'remark-rehype';
10
14
  import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
11
15
  import { t as tailwindPlugin } from './tailwind-DV23JSh-.mjs';
12
16
  import mdx from '@mdx-js/esbuild';
@@ -14,19 +18,23 @@ import glob from 'fast-glob';
14
18
  import { getBrowserGlobals, getDocument, renderSync, renderToString } from 'defuss/server';
15
19
  import { cp, readFile, writeFile } from 'node:fs/promises';
16
20
  import { fileURLToPath } from 'node:url';
17
- import { execSync } from 'node:child_process';
18
21
 
19
22
  const remarkPlugins = [
23
+ remarkParse,
20
24
  // Parse both YAML and TOML (or omit options to default to YAML)
21
25
  [remarkFrontmatter, ["yaml", "toml"]],
22
26
  // Export each key as an ESM binding: export const title = "…"
23
27
  [remarkMdxFrontmatter, { name: "meta" }],
28
+ // GitHub Flavored Markdown (tables, task lists, strikethrough, etc.)
29
+ remarkGfm,
30
+ remarkRehype,
24
31
  // Convert $…$ and $$…$$ into math nodes for KaTeX
25
32
  remarkMath
26
33
  ];
27
34
  const rehypePlugins = [
28
35
  //rehypeMdxTitle,
29
- rehypeKatex
36
+ rehypeKatex,
37
+ rehypeStringify
30
38
  ];
31
39
 
32
40
  const readConfig = async (projectDir, debug) => {
@@ -87,47 +95,6 @@ const validateProjectDir = (projectDir) => {
87
95
  return { code: "OK", message: "Project directory is valid." };
88
96
  };
89
97
 
90
- const setup = async (projectDir) => {
91
- const projectDirStatus = validateProjectDir(projectDir);
92
- if (projectDirStatus.code !== "OK") return projectDirStatus;
93
- const packageJsonPath = join(projectDir, "package.json");
94
- if (!existsSync(packageJsonPath)) {
95
- return {
96
- code: "MISSING_PACKAGE_JSON",
97
- message: `package.json not found in ${projectDir}`
98
- };
99
- }
100
- let packageJson;
101
- try {
102
- packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
103
- } catch (error) {
104
- return {
105
- code: "INVALID_JSON",
106
- message: `Error reading package.json in ${projectDir}: ${error.message}`
107
- };
108
- }
109
- const packageManager = packageJson.packageManager || "npm";
110
- const pm = packageManager.split("@")[0];
111
- const validPMs = ["npm", "yarn", "pnpm", "bun"];
112
- if (!validPMs.includes(pm)) {
113
- return {
114
- code: "UNSUPPORTED_PM",
115
- message: `Unsupported package manager: ${pm}`
116
- };
117
- }
118
- console.log(`Setting up project in ${projectDir} using ${pm}...`);
119
- try {
120
- execSync(`${pm} install`, { cwd: projectDir, stdio: "inherit" });
121
- console.log("Dependencies installed successfully.");
122
- } catch (error) {
123
- return {
124
- code: "INSTALL_FAILED",
125
- message: `Failed to install dependencies: ${error.message}`
126
- };
127
- }
128
- return { code: "OK", message: "Setup completed successfully" };
129
- };
130
-
131
98
  const __filename = fileURLToPath(import.meta.url);
132
99
  const __dirname = dirname(__filename);
133
100
  const build = async ({
@@ -137,7 +104,6 @@ const build = async ({
137
104
  }) => {
138
105
  const projectDirStatus = validateProjectDir(projectDir);
139
106
  if (projectDirStatus.code !== "OK") return projectDirStatus;
140
- await setup(projectDir);
141
107
  const startTime = performance.now();
142
108
  const config = await readConfig(projectDir, debug);
143
109
  if (debug) {
@@ -387,6 +353,8 @@ const serve = async ({
387
353
  isBuilding = true;
388
354
  try {
389
355
  await build({ projectDir, debug, mode: "serve" });
356
+ } catch (error) {
357
+ console.error("Build failed. Waiting for code change to fix that...");
390
358
  } finally {
391
359
  isBuilding = false;
392
360
  if (pendingBuild) {
@@ -426,4 +394,4 @@ const serve = async ({
426
394
  return { code: "OK", message: "Server is running" };
427
395
  };
428
396
 
429
- export { rehypePlugins as a, readConfig as b, configDefaults as c, build as d, remarkPlugins as r, serve as s };
397
+ export { rehypePlugins as a, readConfig as b, configDefaults as c, build as d, remarkPlugins as r, serve as s, validateProjectDir as v };
@@ -6,9 +6,13 @@ var serveStatic = require('serve-static');
6
6
  var node_path = require('node:path');
7
7
  var node_fs = require('node:fs');
8
8
  var esbuild = require('esbuild');
9
- var remarkFrontmatter = require('remark-frontmatter');
10
9
  var rehypeKatex = require('rehype-katex');
10
+ var rehypeStringify = require('rehype-stringify');
11
+ var remarkFrontmatter = require('remark-frontmatter');
11
12
  var remarkMath = require('remark-math');
13
+ var remarkGfm = require('remark-gfm');
14
+ var remarkParse = require('remark-parse');
15
+ var remarkRehype = require('remark-rehype');
12
16
  var remarkMdxFrontmatter = require('remark-mdx-frontmatter');
13
17
  var tailwind = require('./tailwind-C4AuHybm.cjs');
14
18
  var mdx = require('@mdx-js/esbuild');
@@ -16,20 +20,24 @@ var glob = require('fast-glob');
16
20
  var server = require('defuss/server');
17
21
  var promises = require('node:fs/promises');
18
22
  var node_url = require('node:url');
19
- var node_child_process = require('node:child_process');
20
23
 
21
24
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
22
25
  const remarkPlugins = [
26
+ remarkParse,
23
27
  // Parse both YAML and TOML (or omit options to default to YAML)
24
28
  [remarkFrontmatter, ["yaml", "toml"]],
25
29
  // Export each key as an ESM binding: export const title = "…"
26
30
  [remarkMdxFrontmatter, { name: "meta" }],
31
+ // GitHub Flavored Markdown (tables, task lists, strikethrough, etc.)
32
+ remarkGfm,
33
+ remarkRehype,
27
34
  // Convert $…$ and $$…$$ into math nodes for KaTeX
28
35
  remarkMath
29
36
  ];
30
37
  const rehypePlugins = [
31
38
  //rehypeMdxTitle,
32
- rehypeKatex
39
+ rehypeKatex,
40
+ rehypeStringify
33
41
  ];
34
42
 
35
43
  const readConfig = async (projectDir, debug) => {
@@ -90,48 +98,7 @@ const validateProjectDir = (projectDir) => {
90
98
  return { code: "OK", message: "Project directory is valid." };
91
99
  };
92
100
 
93
- const setup = async (projectDir) => {
94
- const projectDirStatus = validateProjectDir(projectDir);
95
- if (projectDirStatus.code !== "OK") return projectDirStatus;
96
- const packageJsonPath = node_path.join(projectDir, "package.json");
97
- if (!node_fs.existsSync(packageJsonPath)) {
98
- return {
99
- code: "MISSING_PACKAGE_JSON",
100
- message: `package.json not found in ${projectDir}`
101
- };
102
- }
103
- let packageJson;
104
- try {
105
- packageJson = JSON.parse(node_fs.readFileSync(packageJsonPath, "utf-8"));
106
- } catch (error) {
107
- return {
108
- code: "INVALID_JSON",
109
- message: `Error reading package.json in ${projectDir}: ${error.message}`
110
- };
111
- }
112
- const packageManager = packageJson.packageManager || "npm";
113
- const pm = packageManager.split("@")[0];
114
- const validPMs = ["npm", "yarn", "pnpm", "bun"];
115
- if (!validPMs.includes(pm)) {
116
- return {
117
- code: "UNSUPPORTED_PM",
118
- message: `Unsupported package manager: ${pm}`
119
- };
120
- }
121
- console.log(`Setting up project in ${projectDir} using ${pm}...`);
122
- try {
123
- node_child_process.execSync(`${pm} install`, { cwd: projectDir, stdio: "inherit" });
124
- console.log("Dependencies installed successfully.");
125
- } catch (error) {
126
- return {
127
- code: "INSTALL_FAILED",
128
- message: `Failed to install dependencies: ${error.message}`
129
- };
130
- }
131
- return { code: "OK", message: "Setup completed successfully" };
132
- };
133
-
134
- const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('serve-DvB62foO.cjs', document.baseURI).href)));
101
+ const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('serve-KTJqW3m0.cjs', document.baseURI).href)));
135
102
  const __dirname$1 = node_path.dirname(__filename$1);
136
103
  const build = async ({
137
104
  projectDir,
@@ -140,7 +107,6 @@ const build = async ({
140
107
  }) => {
141
108
  const projectDirStatus = validateProjectDir(projectDir);
142
109
  if (projectDirStatus.code !== "OK") return projectDirStatus;
143
- await setup(projectDir);
144
110
  const startTime = performance.now();
145
111
  const config = await readConfig(projectDir, debug);
146
112
  if (debug) {
@@ -390,6 +356,8 @@ const serve = async ({
390
356
  isBuilding = true;
391
357
  try {
392
358
  await build({ projectDir, debug, mode: "serve" });
359
+ } catch (error) {
360
+ console.error("Build failed. Waiting for code change to fix that...");
393
361
  } finally {
394
362
  isBuilding = false;
395
363
  if (pendingBuild) {
@@ -435,3 +403,4 @@ exports.readConfig = readConfig;
435
403
  exports.rehypePlugins = rehypePlugins;
436
404
  exports.remarkPlugins = remarkPlugins;
437
405
  exports.serve = serve;
406
+ exports.validateProjectDir = validateProjectDir;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "defuss-ssg",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -83,7 +83,11 @@
83
83
  "esbuild": "^0.25.9",
84
84
  "rehype-mdx-title": "^3.2.0",
85
85
  "rehype-katex": "^7.0.1",
86
+ "rehype-stringify": "^10.0.1",
87
+ "remark-rehype": "^11.1.2",
86
88
  "remark-math": "^6.0.0",
89
+ "remark-gfm": "^4.0.1",
90
+ "remark-parse": "^11.0.0",
87
91
  "remark-frontmatter": "^5.0.0",
88
92
  "remark-mdx-frontmatter": "^5.2.0",
89
93
  "fast-glob": "^3.3.3",