docula 0.9.5 → 0.10.0
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/docula.d.ts +1 -1
- package/dist/docula.js +28 -21
- package/package.json +12 -12
package/dist/docula.d.ts
CHANGED
|
@@ -131,7 +131,7 @@ declare class Docula {
|
|
|
131
131
|
* @param {DoculaOptions} options
|
|
132
132
|
* @returns {Promise<void>}
|
|
133
133
|
*/
|
|
134
|
-
serve(options: DoculaOptions): Promise<
|
|
134
|
+
serve(options: DoculaOptions): Promise<http.Server>;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
export { DoculaHelpers, Docula as default };
|
package/dist/docula.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// src/docula.ts
|
|
2
|
+
import http from "node:http";
|
|
2
3
|
import path3 from "node:path";
|
|
3
4
|
import process3 from "node:process";
|
|
4
5
|
import fs3 from "node:fs";
|
|
6
|
+
import handler from "serve-handler";
|
|
5
7
|
import updateNotifier from "update-notifier";
|
|
6
|
-
import express from "express";
|
|
7
8
|
|
|
8
9
|
// src/options.ts
|
|
9
10
|
import path from "node:path";
|
|
@@ -213,7 +214,7 @@ var DoculaConsole = class {
|
|
|
213
214
|
// src/builder.ts
|
|
214
215
|
import fs from "node:fs";
|
|
215
216
|
import { Ecto } from "ecto";
|
|
216
|
-
import
|
|
217
|
+
import { Writr } from "writr";
|
|
217
218
|
import he from "he";
|
|
218
219
|
import * as cheerio from "cheerio";
|
|
219
220
|
|
|
@@ -618,8 +619,9 @@ var DoculaBuilder = class {
|
|
|
618
619
|
}
|
|
619
620
|
parseDocumentData(documentPath) {
|
|
620
621
|
const documentContent = fs.readFileSync(documentPath, "utf8");
|
|
621
|
-
const
|
|
622
|
-
|
|
622
|
+
const writr = new Writr(documentContent);
|
|
623
|
+
const matterData = writr.frontMatter;
|
|
624
|
+
let markdownContent = writr.body;
|
|
623
625
|
markdownContent = markdownContent.replace(/^# .*\n/, "");
|
|
624
626
|
const documentsFolderIndex = documentPath.lastIndexOf("/docs/");
|
|
625
627
|
let urlPath = documentPath.slice(documentsFolderIndex).replace(".md", "/index.html");
|
|
@@ -633,17 +635,17 @@ var DoculaBuilder = class {
|
|
|
633
635
|
}
|
|
634
636
|
return {
|
|
635
637
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
636
|
-
title: matterData.
|
|
638
|
+
title: matterData.title,
|
|
637
639
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
638
|
-
navTitle: matterData.
|
|
640
|
+
navTitle: matterData.navTitle || matterData.title,
|
|
639
641
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
640
|
-
description: matterData.
|
|
642
|
+
description: matterData.description || "",
|
|
641
643
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
642
|
-
order: matterData.
|
|
644
|
+
order: matterData.order || void 0,
|
|
643
645
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
644
|
-
section: matterData.
|
|
646
|
+
section: matterData.section || void 0,
|
|
645
647
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
646
|
-
keywords: matterData.
|
|
648
|
+
keywords: matterData.keywords || [],
|
|
647
649
|
content: documentContent,
|
|
648
650
|
markdown: markdownContent,
|
|
649
651
|
generatedHtml: this._ecto.renderSync(markdownContent, void 0, "markdown"),
|
|
@@ -653,9 +655,6 @@ var DoculaBuilder = class {
|
|
|
653
655
|
isRoot
|
|
654
656
|
};
|
|
655
657
|
}
|
|
656
|
-
removeFrontmatter(markdown) {
|
|
657
|
-
return markdown.replace(/^-{3}[\s\S]*?-{3}\s*/, "");
|
|
658
|
-
}
|
|
659
658
|
getTableOfContents(markdown) {
|
|
660
659
|
markdown = `## Table of Contents
|
|
661
660
|
|
|
@@ -691,7 +690,7 @@ ${markdown}`;
|
|
|
691
690
|
|
|
692
691
|
// src/helpers.ts
|
|
693
692
|
import fs2 from "node:fs";
|
|
694
|
-
import { Writr } from "writr";
|
|
693
|
+
import { Writr as Writr2 } from "writr";
|
|
695
694
|
var DoculaHelpers = class {
|
|
696
695
|
createDoc(path4, destination, frontMatter, contentFunction) {
|
|
697
696
|
const content = fs2.readFileSync(path4, "utf8");
|
|
@@ -702,16 +701,16 @@ var DoculaHelpers = class {
|
|
|
702
701
|
fs2.writeFileSync(destination, newContent, "utf8");
|
|
703
702
|
}
|
|
704
703
|
getFrontMatterFromFile(path4) {
|
|
705
|
-
const writr = new
|
|
704
|
+
const writr = new Writr2();
|
|
706
705
|
writr.loadFromFileSync(path4);
|
|
707
706
|
return writr.frontMatter;
|
|
708
707
|
}
|
|
709
708
|
getFrontMatter(content) {
|
|
710
|
-
const writr = new
|
|
709
|
+
const writr = new Writr2(content);
|
|
711
710
|
return writr.frontMatter;
|
|
712
711
|
}
|
|
713
712
|
setFrontMatterToFile(path4, frontMatter) {
|
|
714
|
-
const writr = new
|
|
713
|
+
const writr = new Writr2();
|
|
715
714
|
writr.loadFromFileSync(path4);
|
|
716
715
|
writr.frontMatter = frontMatter;
|
|
717
716
|
fs2.writeFileSync(path4, writr.content, "utf8");
|
|
@@ -720,7 +719,7 @@ var DoculaHelpers = class {
|
|
|
720
719
|
if (!frontMatter) {
|
|
721
720
|
return content;
|
|
722
721
|
}
|
|
723
|
-
const writr = new
|
|
722
|
+
const writr = new Writr2(content);
|
|
724
723
|
writr.frontMatter = frontMatter;
|
|
725
724
|
return writr.content;
|
|
726
725
|
}
|
|
@@ -894,13 +893,21 @@ var Docula = class {
|
|
|
894
893
|
if (this._server) {
|
|
895
894
|
this._server.close();
|
|
896
895
|
}
|
|
897
|
-
const app = express();
|
|
898
896
|
const { port } = options;
|
|
899
897
|
const { outputPath } = options;
|
|
900
|
-
|
|
901
|
-
|
|
898
|
+
const config = {
|
|
899
|
+
public: outputPath
|
|
900
|
+
};
|
|
901
|
+
this._server = http.createServer(
|
|
902
|
+
async (request, response) => (
|
|
903
|
+
/* c8 ignore next */
|
|
904
|
+
handler(request, response, config)
|
|
905
|
+
)
|
|
906
|
+
);
|
|
907
|
+
this._server.listen(port, () => {
|
|
902
908
|
this._console.log(`Docula \u{1F987} at http://localhost:${port}`);
|
|
903
909
|
});
|
|
910
|
+
return this._server;
|
|
904
911
|
}
|
|
905
912
|
};
|
|
906
913
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docula",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Beautiful Website for Your Projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/docula.js",
|
|
@@ -46,29 +46,29 @@
|
|
|
46
46
|
"docula": "./bin/docula.mjs"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"axios": "^1.7.
|
|
49
|
+
"axios": "^1.7.9",
|
|
50
50
|
"cheerio": "^1.0.0",
|
|
51
|
-
"ecto": "^4.1.
|
|
52
|
-
"express": "^4.21.1",
|
|
51
|
+
"ecto": "^4.1.5",
|
|
53
52
|
"feed": "^4.2.2",
|
|
54
|
-
"gray-matter": "^4.0.3",
|
|
55
53
|
"he": "^1.2.0",
|
|
54
|
+
"serve-handler": "^6.1.6",
|
|
56
55
|
"update-notifier": "^7.3.1",
|
|
57
|
-
"writr": "^4.
|
|
56
|
+
"writr": "^4.3.0"
|
|
58
57
|
},
|
|
59
58
|
"devDependencies": {
|
|
60
59
|
"@types/express": "^5.0.0",
|
|
61
60
|
"@types/he": "^1.2.3",
|
|
62
61
|
"@types/js-yaml": "^4.0.9",
|
|
63
|
-
"@types/node": "^22.
|
|
62
|
+
"@types/node": "^22.10.7",
|
|
63
|
+
"@types/serve-handler": "^6.1.4",
|
|
64
64
|
"@types/update-notifier": "^6.0.8",
|
|
65
|
-
"@vitest/coverage-v8": "^
|
|
65
|
+
"@vitest/coverage-v8": "^3.0.2",
|
|
66
66
|
"rimraf": "^6.0.1",
|
|
67
67
|
"tsup": "^8.3.5",
|
|
68
|
-
"typescript": "^5.
|
|
69
|
-
"vitest": "^
|
|
70
|
-
"webpack": "^5.
|
|
71
|
-
"xo": "^0.
|
|
68
|
+
"typescript": "^5.7.3",
|
|
69
|
+
"vitest": "^3.0.2",
|
|
70
|
+
"webpack": "^5.97.1",
|
|
71
|
+
"xo": "^0.60.0"
|
|
72
72
|
},
|
|
73
73
|
"xo": {
|
|
74
74
|
"ignores": [
|