file2site 0.1.3 → 0.1.4
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/dist/cli.js +5 -4
- package/dist/server.js +10 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8,8 +8,8 @@ import { writeFile } from "node:fs/promises";
|
|
|
8
8
|
const program = new Command();
|
|
9
9
|
program
|
|
10
10
|
.name("file2site")
|
|
11
|
-
.description("Turn a single Markdown, HTML, JSON, or
|
|
12
|
-
.argument("<file>", "Markdown (.md), HTML (.html), JSON (.json),
|
|
11
|
+
.description("Turn a single Markdown, HTML, JSON, YAML, or text file into a live website")
|
|
12
|
+
.argument("<file>", "Markdown (.md), HTML (.html), JSON (.json), YAML (.yaml/.yml), or text (.txt) file")
|
|
13
13
|
.option("--port <number>", "Use a specific port")
|
|
14
14
|
.option("--no-open", "Do not open the browser")
|
|
15
15
|
.option("--export", "Export a static HTML file and exit")
|
|
@@ -17,7 +17,7 @@ program
|
|
|
17
17
|
const resolvedPath = resolve(process.cwd(), file);
|
|
18
18
|
const extension = extname(resolvedPath).toLowerCase();
|
|
19
19
|
if (!isSupportedExtension(extension)) {
|
|
20
|
-
console.error("Error: Supported files are .md, .html, .json, .yaml, and .
|
|
20
|
+
console.error("Error: Supported files are .md, .html, .json, .yaml, .yml, and .txt.");
|
|
21
21
|
process.exit(1);
|
|
22
22
|
}
|
|
23
23
|
try {
|
|
@@ -63,7 +63,8 @@ function isSupportedExtension(extension) {
|
|
|
63
63
|
extension === ".html" ||
|
|
64
64
|
extension === ".json" ||
|
|
65
65
|
extension === ".yaml" ||
|
|
66
|
-
extension === ".yml"
|
|
66
|
+
extension === ".yml" ||
|
|
67
|
+
extension === ".txt");
|
|
67
68
|
}
|
|
68
69
|
function getExportPath(filePath, extension) {
|
|
69
70
|
if (extension === ".md") {
|
package/dist/server.js
CHANGED
|
@@ -39,6 +39,14 @@ export async function renderFileToHtml(filePath, options) {
|
|
|
39
39
|
themeCss
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
+
if (extension === ".txt") {
|
|
43
|
+
const result = renderMarkdown(`\`\`\`text\n${source}\n\`\`\``, options.titleFallback);
|
|
44
|
+
return renderHtmlDocument(result.html, {
|
|
45
|
+
title: result.title,
|
|
46
|
+
includeReload: options.includeReload,
|
|
47
|
+
themeCss
|
|
48
|
+
});
|
|
49
|
+
}
|
|
42
50
|
const title = options.titleFallback || basename(filePath);
|
|
43
51
|
const centered = `<div class=\"html-center\">${source}</div>`;
|
|
44
52
|
return renderHtmlDocument(centered, {
|
|
@@ -65,6 +73,8 @@ function getExtension(filePath) {
|
|
|
65
73
|
return ".yaml";
|
|
66
74
|
if (lower.endsWith(".yml"))
|
|
67
75
|
return ".yml";
|
|
76
|
+
if (lower.endsWith(".txt"))
|
|
77
|
+
return ".txt";
|
|
68
78
|
return ".html";
|
|
69
79
|
}
|
|
70
80
|
export async function startServer(options) {
|