@rettangoli/sites 0.2.0-rc7 → 0.2.1
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/package.json +3 -2
- package/src/cli/build.js +2 -2
- package/src/createSiteBuilder.js +14 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rettangoli/sites",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Generate static sites using Markdown and YAML. Straightforward, zero-complexity. Complete toolkit for landing pages, blogs, documentation, admin dashboards, and more.git remote add origin git@github.com:yuusoft-org/sitic.git",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Luciano Hanyon Wu",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"memfs": "^4.36.0",
|
|
31
|
-
"puty": "^0.0.4"
|
|
31
|
+
"puty": "^0.0.4",
|
|
32
|
+
"vitest": "^3.2.4"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"test": "vitest run --reporter=verbose"
|
package/src/cli/build.js
CHANGED
|
@@ -21,10 +21,10 @@ export const buildSite = async (options = {}) => {
|
|
|
21
21
|
const build = createSiteBuilder({
|
|
22
22
|
fs,
|
|
23
23
|
rootDir,
|
|
24
|
-
md: md || config.
|
|
24
|
+
md: md || config.mdRender,
|
|
25
25
|
functions: functions || config.functions || {},
|
|
26
26
|
quiet
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
build();
|
|
29
|
+
await build();
|
|
30
30
|
};
|
package/src/createSiteBuilder.js
CHANGED
|
@@ -32,7 +32,7 @@ function isObject(item) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet = false }) {
|
|
35
|
-
return function build() {
|
|
35
|
+
return async function build() {
|
|
36
36
|
// Use provided md or default to rtglMarkdown
|
|
37
37
|
const mdInstance = md || rtglMarkdown(MarkdownIt);
|
|
38
38
|
|
|
@@ -191,7 +191,7 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
191
191
|
const collections = buildCollections();
|
|
192
192
|
|
|
193
193
|
// Function to process a single page file
|
|
194
|
-
function processPage(pagePath, outputRelativePath, isMarkdown = false) {
|
|
194
|
+
async function processPage(pagePath, outputRelativePath, isMarkdown = false) {
|
|
195
195
|
if (!quiet) console.log(`Processing ${pagePath}...`);
|
|
196
196
|
|
|
197
197
|
// Read page content
|
|
@@ -245,7 +245,13 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
245
245
|
|
|
246
246
|
if (isMarkdown) {
|
|
247
247
|
// Process markdown content with MarkdownIt
|
|
248
|
-
|
|
248
|
+
//If markdownit async then use the async render method
|
|
249
|
+
let htmlContent;
|
|
250
|
+
if(mdInstance.renderAsync){
|
|
251
|
+
htmlContent = await mdInstance.renderAsync(rawContent);
|
|
252
|
+
} else {
|
|
253
|
+
htmlContent = mdInstance.render(rawContent);
|
|
254
|
+
}
|
|
249
255
|
// For markdown, store as raw HTML that will be inserted directly
|
|
250
256
|
processedPageContent = { __html: htmlContent };
|
|
251
257
|
} else {
|
|
@@ -305,7 +311,7 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
305
311
|
}
|
|
306
312
|
|
|
307
313
|
// Process all YAML and Markdown files in pages directory recursively
|
|
308
|
-
function processAllPages(dir, basePath = '') {
|
|
314
|
+
async function processAllPages(dir, basePath = '') {
|
|
309
315
|
const pagesDir = path.join(rootDir, 'pages');
|
|
310
316
|
const fullDir = path.join(pagesDir, basePath);
|
|
311
317
|
|
|
@@ -319,18 +325,18 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
319
325
|
|
|
320
326
|
if (item.isDirectory()) {
|
|
321
327
|
// Recursively process subdirectories
|
|
322
|
-
processAllPages(dir, relativePath);
|
|
328
|
+
await processAllPages(dir, relativePath);
|
|
323
329
|
} else if (item.isFile()) {
|
|
324
330
|
if (item.name.endsWith('.yaml')) {
|
|
325
331
|
// Process YAML file
|
|
326
332
|
const outputFileName = item.name.replace('.yaml', '.html');
|
|
327
333
|
const outputRelativePath = basePath ? path.join(basePath, outputFileName) : outputFileName;
|
|
328
|
-
processPage(itemPath, outputRelativePath, false);
|
|
334
|
+
await processPage(itemPath, outputRelativePath, false);
|
|
329
335
|
} else if (item.name.endsWith('.md')) {
|
|
330
336
|
// Process Markdown file
|
|
331
337
|
const outputFileName = item.name.replace('.md', '.html');
|
|
332
338
|
const outputRelativePath = basePath ? path.join(basePath, outputFileName) : outputFileName;
|
|
333
|
-
processPage(itemPath, outputRelativePath, true);
|
|
339
|
+
await processPage(itemPath, outputRelativePath, true);
|
|
334
340
|
}
|
|
335
341
|
// Ignore other file types
|
|
336
342
|
}
|
|
@@ -388,7 +394,7 @@ export function createSiteBuilder({ fs, rootDir = '.', md, functions = {}, quiet
|
|
|
388
394
|
copyStaticFiles();
|
|
389
395
|
|
|
390
396
|
// Process all pages (can overwrite static files)
|
|
391
|
-
processAllPages('');
|
|
397
|
+
await processAllPages('');
|
|
392
398
|
|
|
393
399
|
if (!quiet) console.log('Build complete!');
|
|
394
400
|
};
|