docula 0.9.3 → 0.9.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/dist/docula.d.ts +85 -0
- package/dist/docula.js +98 -30
- package/package.json +9 -9
- package/template/css/base.css +2 -0
package/dist/docula.d.ts
CHANGED
|
@@ -8,15 +8,45 @@ type DoculaSection = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
declare class DoculaOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Path to the template directory
|
|
13
|
+
*/
|
|
11
14
|
templatePath: string;
|
|
15
|
+
/**
|
|
16
|
+
* Path to the output directory
|
|
17
|
+
*/
|
|
12
18
|
outputPath: string;
|
|
19
|
+
/**
|
|
20
|
+
* Path to the site directory
|
|
21
|
+
*/
|
|
13
22
|
sitePath: string;
|
|
23
|
+
/**
|
|
24
|
+
* Path to the github repository
|
|
25
|
+
*/
|
|
14
26
|
githubPath: string;
|
|
27
|
+
/**
|
|
28
|
+
* Site title
|
|
29
|
+
*/
|
|
15
30
|
siteTitle: string;
|
|
31
|
+
/**
|
|
32
|
+
* Site description
|
|
33
|
+
*/
|
|
16
34
|
siteDescription: string;
|
|
35
|
+
/**
|
|
36
|
+
* Site URL
|
|
37
|
+
*/
|
|
17
38
|
siteUrl: string;
|
|
39
|
+
/**
|
|
40
|
+
* Port to run the server
|
|
41
|
+
*/
|
|
18
42
|
port: number;
|
|
43
|
+
/**
|
|
44
|
+
* Single page website
|
|
45
|
+
*/
|
|
19
46
|
singlePage: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Sections
|
|
49
|
+
*/
|
|
20
50
|
sections?: DoculaSection[];
|
|
21
51
|
constructor(options?: Record<string, unknown>);
|
|
22
52
|
parseOptions(options: Record<string, any>): void;
|
|
@@ -35,17 +65,72 @@ declare class Docula {
|
|
|
35
65
|
private readonly _console;
|
|
36
66
|
private _configFileModule;
|
|
37
67
|
private _server;
|
|
68
|
+
/**
|
|
69
|
+
* Initialize the Docula class
|
|
70
|
+
* @param {DoculaOptions} options
|
|
71
|
+
* @returns {void}
|
|
72
|
+
* @constructor
|
|
73
|
+
*/
|
|
38
74
|
constructor(options?: DoculaOptions);
|
|
75
|
+
/**
|
|
76
|
+
* Get the options
|
|
77
|
+
* @returns {DoculaOptions}
|
|
78
|
+
*/
|
|
39
79
|
get options(): DoculaOptions;
|
|
80
|
+
/**
|
|
81
|
+
* Set the options
|
|
82
|
+
* @param {DoculaOptions} value
|
|
83
|
+
*/
|
|
40
84
|
set options(value: DoculaOptions);
|
|
85
|
+
/**
|
|
86
|
+
* The http server used to serve the site
|
|
87
|
+
* @returns {http.Server | undefined}
|
|
88
|
+
*/
|
|
41
89
|
get server(): http.Server | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* The config file module. This is the module that is loaded from the docula.config.mjs file
|
|
92
|
+
* @returns {any}
|
|
93
|
+
*/
|
|
42
94
|
get configFileModule(): any;
|
|
95
|
+
/**
|
|
96
|
+
* Check for updates
|
|
97
|
+
* @returns {void}
|
|
98
|
+
*/
|
|
43
99
|
checkForUpdates(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Is the execution process that runs the docula command
|
|
102
|
+
* @param {NodeJS.Process} process
|
|
103
|
+
* @returns {Promise<void>}
|
|
104
|
+
*/
|
|
44
105
|
execute(process: NodeJS.Process): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Checks if the site is a single page website
|
|
108
|
+
* @param {string} sitePath
|
|
109
|
+
* @returns {boolean}
|
|
110
|
+
*/
|
|
45
111
|
isSinglePageWebsite(sitePath: string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Generate the init files
|
|
114
|
+
* @param {string} sitePath
|
|
115
|
+
* @returns {void}
|
|
116
|
+
*/
|
|
46
117
|
generateInit(sitePath: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Get the version of the package
|
|
120
|
+
* @returns {string}
|
|
121
|
+
*/
|
|
47
122
|
getVersion(): string;
|
|
123
|
+
/**
|
|
124
|
+
* Load the config file
|
|
125
|
+
* @param {string} sitePath
|
|
126
|
+
* @returns {Promise<void>}
|
|
127
|
+
*/
|
|
48
128
|
loadConfigFile(sitePath: string): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Serve the site based on the options (port and output path)
|
|
131
|
+
* @param {DoculaOptions} options
|
|
132
|
+
* @returns {Promise<void>}
|
|
133
|
+
*/
|
|
49
134
|
serve(options: DoculaOptions): Promise<void>;
|
|
50
135
|
}
|
|
51
136
|
|
package/dist/docula.js
CHANGED
|
@@ -9,15 +9,45 @@ import express from "express";
|
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import process from "node:process";
|
|
11
11
|
var DoculaOptions = class {
|
|
12
|
+
/**
|
|
13
|
+
* Path to the template directory
|
|
14
|
+
*/
|
|
12
15
|
templatePath = path.join(import.meta.url, "../../template").replace("file:", "");
|
|
16
|
+
/**
|
|
17
|
+
* Path to the output directory
|
|
18
|
+
*/
|
|
13
19
|
outputPath = path.join(process.cwd(), "./dist");
|
|
20
|
+
/**
|
|
21
|
+
* Path to the site directory
|
|
22
|
+
*/
|
|
14
23
|
sitePath = path.join(process.cwd(), "./site");
|
|
24
|
+
/**
|
|
25
|
+
* Path to the github repository
|
|
26
|
+
*/
|
|
15
27
|
githubPath = "jaredwray/docula";
|
|
28
|
+
/**
|
|
29
|
+
* Site title
|
|
30
|
+
*/
|
|
16
31
|
siteTitle = "docula";
|
|
32
|
+
/**
|
|
33
|
+
* Site description
|
|
34
|
+
*/
|
|
17
35
|
siteDescription = "Beautiful Website for Your Projects";
|
|
36
|
+
/**
|
|
37
|
+
* Site URL
|
|
38
|
+
*/
|
|
18
39
|
siteUrl = "https://docula.org";
|
|
40
|
+
/**
|
|
41
|
+
* Port to run the server
|
|
42
|
+
*/
|
|
19
43
|
port = 3e3;
|
|
44
|
+
/**
|
|
45
|
+
* Single page website
|
|
46
|
+
*/
|
|
20
47
|
singlePage = true;
|
|
48
|
+
/**
|
|
49
|
+
* Sections
|
|
50
|
+
*/
|
|
21
51
|
sections;
|
|
22
52
|
constructor(options) {
|
|
23
53
|
if (options) {
|
|
@@ -661,7 +691,7 @@ ${markdown}`;
|
|
|
661
691
|
|
|
662
692
|
// src/helpers.ts
|
|
663
693
|
import fs2 from "node:fs";
|
|
664
|
-
import {
|
|
694
|
+
import { Writr } from "writr";
|
|
665
695
|
var DoculaHelpers = class {
|
|
666
696
|
createDoc(path4, destination, frontMatter, contentFunction) {
|
|
667
697
|
const content = fs2.readFileSync(path4, "utf8");
|
|
@@ -672,44 +702,27 @@ var DoculaHelpers = class {
|
|
|
672
702
|
fs2.writeFileSync(destination, newContent, "utf8");
|
|
673
703
|
}
|
|
674
704
|
getFrontMatterFromFile(path4) {
|
|
675
|
-
const
|
|
676
|
-
|
|
705
|
+
const writr = new Writr();
|
|
706
|
+
writr.loadFromFileSync(path4);
|
|
707
|
+
return writr.frontMatter;
|
|
677
708
|
}
|
|
678
709
|
getFrontMatter(content) {
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
const frontMatter = load2(match[1]);
|
|
682
|
-
return frontMatter;
|
|
683
|
-
}
|
|
684
|
-
return {};
|
|
710
|
+
const writr = new Writr(content);
|
|
711
|
+
return writr.frontMatter;
|
|
685
712
|
}
|
|
686
713
|
setFrontMatterToFile(path4, frontMatter) {
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
714
|
+
const writr = new Writr();
|
|
715
|
+
writr.loadFromFileSync(path4);
|
|
716
|
+
writr.frontMatter = frontMatter;
|
|
717
|
+
fs2.writeFileSync(path4, writr.content, "utf8");
|
|
690
718
|
}
|
|
691
719
|
setFrontMatterInContent(content, frontMatter) {
|
|
692
720
|
if (!frontMatter) {
|
|
693
721
|
return content;
|
|
694
722
|
}
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
oldFrontMatter = {
|
|
699
|
-
...oldFrontMatter,
|
|
700
|
-
...frontMatter
|
|
701
|
-
};
|
|
702
|
-
const newYaml2 = dump(oldFrontMatter);
|
|
703
|
-
const newContent2 = `---
|
|
704
|
-
${newYaml2}---
|
|
705
|
-
${match[2]}`;
|
|
706
|
-
return newContent2;
|
|
707
|
-
}
|
|
708
|
-
const newYaml = dump(frontMatter);
|
|
709
|
-
const newContent = `---
|
|
710
|
-
${newYaml}---
|
|
711
|
-
${content}`;
|
|
712
|
-
return newContent;
|
|
723
|
+
const writr = new Writr(content);
|
|
724
|
+
writr.frontMatter = frontMatter;
|
|
725
|
+
return writr.content;
|
|
713
726
|
}
|
|
714
727
|
};
|
|
715
728
|
|
|
@@ -719,23 +732,49 @@ var Docula = class {
|
|
|
719
732
|
_console = new DoculaConsole();
|
|
720
733
|
_configFileModule = {};
|
|
721
734
|
_server;
|
|
735
|
+
/**
|
|
736
|
+
* Initialize the Docula class
|
|
737
|
+
* @param {DoculaOptions} options
|
|
738
|
+
* @returns {void}
|
|
739
|
+
* @constructor
|
|
740
|
+
*/
|
|
722
741
|
constructor(options) {
|
|
723
742
|
if (options) {
|
|
724
743
|
this._options = options;
|
|
725
744
|
}
|
|
726
745
|
}
|
|
746
|
+
/**
|
|
747
|
+
* Get the options
|
|
748
|
+
* @returns {DoculaOptions}
|
|
749
|
+
*/
|
|
727
750
|
get options() {
|
|
728
751
|
return this._options;
|
|
729
752
|
}
|
|
753
|
+
/**
|
|
754
|
+
* Set the options
|
|
755
|
+
* @param {DoculaOptions} value
|
|
756
|
+
*/
|
|
730
757
|
set options(value) {
|
|
731
758
|
this._options = value;
|
|
732
759
|
}
|
|
760
|
+
/**
|
|
761
|
+
* The http server used to serve the site
|
|
762
|
+
* @returns {http.Server | undefined}
|
|
763
|
+
*/
|
|
733
764
|
get server() {
|
|
734
765
|
return this._server;
|
|
735
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* The config file module. This is the module that is loaded from the docula.config.mjs file
|
|
769
|
+
* @returns {any}
|
|
770
|
+
*/
|
|
736
771
|
get configFileModule() {
|
|
737
772
|
return this._configFileModule;
|
|
738
773
|
}
|
|
774
|
+
/**
|
|
775
|
+
* Check for updates
|
|
776
|
+
* @returns {void}
|
|
777
|
+
*/
|
|
739
778
|
checkForUpdates() {
|
|
740
779
|
const packageJsonPath = path3.join(process3.cwd(), "package.json");
|
|
741
780
|
if (fs3.existsSync(packageJsonPath)) {
|
|
@@ -743,6 +782,11 @@ var Docula = class {
|
|
|
743
782
|
updateNotifier({ pkg: packageJson }).notify();
|
|
744
783
|
}
|
|
745
784
|
}
|
|
785
|
+
/**
|
|
786
|
+
* Is the execution process that runs the docula command
|
|
787
|
+
* @param {NodeJS.Process} process
|
|
788
|
+
* @returns {Promise<void>}
|
|
789
|
+
*/
|
|
746
790
|
async execute(process4) {
|
|
747
791
|
this.checkForUpdates();
|
|
748
792
|
const consoleProcess = this._console.parseProcessArgv(process4.argv);
|
|
@@ -790,6 +834,11 @@ var Docula = class {
|
|
|
790
834
|
}
|
|
791
835
|
}
|
|
792
836
|
}
|
|
837
|
+
/**
|
|
838
|
+
* Checks if the site is a single page website
|
|
839
|
+
* @param {string} sitePath
|
|
840
|
+
* @returns {boolean}
|
|
841
|
+
*/
|
|
793
842
|
isSinglePageWebsite(sitePath) {
|
|
794
843
|
const documentationPath = `${sitePath}/docs`;
|
|
795
844
|
if (!fs3.existsSync(documentationPath)) {
|
|
@@ -798,6 +847,11 @@ var Docula = class {
|
|
|
798
847
|
const files = fs3.readdirSync(documentationPath);
|
|
799
848
|
return files.length === 0;
|
|
800
849
|
}
|
|
850
|
+
/**
|
|
851
|
+
* Generate the init files
|
|
852
|
+
* @param {string} sitePath
|
|
853
|
+
* @returns {void}
|
|
854
|
+
*/
|
|
801
855
|
generateInit(sitePath) {
|
|
802
856
|
if (!fs3.existsSync(sitePath)) {
|
|
803
857
|
fs3.mkdirSync(sitePath);
|
|
@@ -809,11 +863,20 @@ var Docula = class {
|
|
|
809
863
|
fs3.copyFileSync("./init/variables.css", `${sitePath}/variables.css`);
|
|
810
864
|
this._console.log(`docula initialized. Please update the ${doculaConfigFile} file with your site information. In addition, you can replace the image, favicon, and stype the site with site.css file.`);
|
|
811
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* Get the version of the package
|
|
868
|
+
* @returns {string}
|
|
869
|
+
*/
|
|
812
870
|
getVersion() {
|
|
813
871
|
const packageJson = fs3.readFileSync("./package.json", "utf8");
|
|
814
872
|
const packageObject = JSON.parse(packageJson);
|
|
815
873
|
return packageObject.version;
|
|
816
874
|
}
|
|
875
|
+
/**
|
|
876
|
+
* Load the config file
|
|
877
|
+
* @param {string} sitePath
|
|
878
|
+
* @returns {Promise<void>}
|
|
879
|
+
*/
|
|
817
880
|
async loadConfigFile(sitePath) {
|
|
818
881
|
if (fs3.existsSync(sitePath)) {
|
|
819
882
|
const configFile = `${sitePath}/docula.config.mjs`;
|
|
@@ -822,6 +885,11 @@ var Docula = class {
|
|
|
822
885
|
}
|
|
823
886
|
}
|
|
824
887
|
}
|
|
888
|
+
/**
|
|
889
|
+
* Serve the site based on the options (port and output path)
|
|
890
|
+
* @param {DoculaOptions} options
|
|
891
|
+
* @returns {Promise<void>}
|
|
892
|
+
*/
|
|
825
893
|
async serve(options) {
|
|
826
894
|
if (this._server) {
|
|
827
895
|
this._server.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docula",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Beautiful Website for Your Projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/docula.js",
|
|
@@ -48,26 +48,26 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"axios": "^1.7.7",
|
|
50
50
|
"cheerio": "^1.0.0",
|
|
51
|
-
"ecto": "^4.1.
|
|
51
|
+
"ecto": "^4.1.3",
|
|
52
52
|
"express": "^4.21.1",
|
|
53
53
|
"feed": "^4.2.2",
|
|
54
54
|
"gray-matter": "^4.0.3",
|
|
55
55
|
"he": "^1.2.0",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
56
|
+
"update-notifier": "^7.3.1",
|
|
57
|
+
"writr": "^4.1.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/express": "^5.0.0",
|
|
61
61
|
"@types/he": "^1.2.3",
|
|
62
62
|
"@types/js-yaml": "^4.0.9",
|
|
63
|
-
"@types/node": "^22.
|
|
63
|
+
"@types/node": "^22.9.0",
|
|
64
64
|
"@types/update-notifier": "^6.0.8",
|
|
65
|
-
"@vitest/coverage-v8": "^2.1.
|
|
65
|
+
"@vitest/coverage-v8": "^2.1.5",
|
|
66
66
|
"rimraf": "^6.0.1",
|
|
67
|
-
"tsup": "^8.3.
|
|
67
|
+
"tsup": "^8.3.5",
|
|
68
68
|
"typescript": "^5.6.3",
|
|
69
|
-
"vitest": "^2.1.
|
|
70
|
-
"webpack": "^5.
|
|
69
|
+
"vitest": "^2.1.5",
|
|
70
|
+
"webpack": "^5.96.1",
|
|
71
71
|
"xo": "^0.59.3"
|
|
72
72
|
},
|
|
73
73
|
"xo": {
|