docula 0.3.2 → 0.3.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/README.md +1 -1
- package/dist/config.d.ts +21 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +78 -0
- package/dist/config.js.map +1 -0
- package/dist/docula-plugin.d.ts +9 -0
- package/dist/docula-plugin.d.ts.map +1 -0
- package/dist/docula-plugin.js +2 -0
- package/dist/docula-plugin.js.map +1 -0
- package/dist/docula.d.ts +22 -0
- package/dist/docula.d.ts.map +1 -0
- package/dist/docula.js +192 -0
- package/dist/docula.js.map +1 -0
- package/dist/eleventy/filters.d.ts +2 -0
- package/dist/eleventy/filters.d.ts.map +1 -0
- package/dist/eleventy/filters.js +10 -0
- package/dist/eleventy/filters.js.map +1 -0
- package/dist/eleventy/global-data.d.ts +3 -0
- package/dist/eleventy/global-data.d.ts.map +1 -0
- package/dist/eleventy/global-data.js +2 -0
- package/dist/eleventy/global-data.js.map +1 -0
- package/dist/eleventy/shortcodes.d.ts +4 -0
- package/dist/eleventy/shortcodes.d.ts.map +1 -0
- package/dist/eleventy/shortcodes.js +18 -0
- package/dist/eleventy/shortcodes.js.map +1 -0
- package/dist/eleventy.d.ts +24 -0
- package/dist/eleventy.d.ts.map +1 -0
- package/dist/eleventy.js +82 -0
- package/dist/eleventy.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +20 -0
- package/dist/logger.js.map +1 -0
- package/dist/plugins/algolia.d.ts +21 -0
- package/dist/plugins/algolia.d.ts.map +1 -0
- package/dist/plugins/algolia.js +54 -0
- package/dist/plugins/algolia.js.map +1 -0
- package/dist/plugins/github.d.ts +16 -0
- package/dist/plugins/github.d.ts.map +1 -0
- package/dist/plugins/github.js +68 -0
- package/dist/plugins/github.js.map +1 -0
- package/dist/plugins/index.d.ts +18 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +16 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/npm.d.ts +14 -0
- package/dist/plugins/npm.d.ts.map +1 -0
- package/dist/plugins/npm.js +36 -0
- package/dist/plugins/npm.js.map +1 -0
- package/dist/plugins/pagefind.d.ts +10 -0
- package/dist/plugins/pagefind.d.ts.map +1 -0
- package/dist/plugins/pagefind.js +22 -0
- package/dist/plugins/pagefind.js.map +1 -0
- package/dist/plugins/robots.d.ts +14 -0
- package/dist/plugins/robots.d.ts.map +1 -0
- package/dist/plugins/robots.js +34 -0
- package/dist/plugins/robots.js.map +1 -0
- package/dist/plugins/sitemap.d.ts +11 -0
- package/dist/plugins/sitemap.d.ts.map +1 -0
- package/dist/plugins/sitemap.js +27 -0
- package/dist/plugins/sitemap.js.map +1 -0
- package/dist/schemas.d.ts +21 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +25 -0
- package/dist/schemas.js.map +1 -0
- package/dist/tools/__mocks__/inquirer-prompt.d.ts +20 -0
- package/dist/tools/__mocks__/inquirer-prompt.d.ts.map +1 -0
- package/dist/tools/__mocks__/inquirer-prompt.js +19 -0
- package/dist/tools/__mocks__/inquirer-prompt.js.map +1 -0
- package/dist/tools/__mocks__/path.d.ts +5 -0
- package/dist/tools/__mocks__/path.d.ts.map +1 -0
- package/dist/tools/__mocks__/path.js +7 -0
- package/dist/tools/__mocks__/path.js.map +1 -0
- package/dist/tools/inquirer-prompt.d.ts +11 -0
- package/dist/tools/inquirer-prompt.d.ts.map +1 -0
- package/dist/tools/inquirer-prompt.js +139 -0
- package/dist/tools/inquirer-prompt.js.map +1 -0
- package/dist/tools/path.d.ts +4 -0
- package/dist/tools/path.d.ts.map +1 -0
- package/dist/tools/path.js +6 -0
- package/dist/tools/path.js.map +1 -0
- package/dist/tools/tools.d.ts +3 -0
- package/dist/tools/tools.d.ts.map +1 -0
- package/dist/tools/tools.js +10 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/types/config.d.ts +8 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/package.json +13 -15
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createCommand } from 'commander';
|
|
2
|
+
import { Docula } from './docula.js';
|
|
3
|
+
import { reportError } from './tools/tools.js';
|
|
4
|
+
import logger from './logger.js';
|
|
5
|
+
export class Executable {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
async parseCLI(process) {
|
|
8
|
+
const program = createCommand();
|
|
9
|
+
program.storeOptionsAsProperties(true);
|
|
10
|
+
program.command('build', { isDefault: true })
|
|
11
|
+
.description('Build the site')
|
|
12
|
+
.option('-c, --config <config>', 'Path of where the config file is located')
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
try {
|
|
15
|
+
logger.info('Building your documentation...');
|
|
16
|
+
const docula = new Docula(options);
|
|
17
|
+
await docula.build();
|
|
18
|
+
logger.info('Site was built successfully!');
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
reportError(error);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
program.command('init')
|
|
25
|
+
.description('Initialize the site')
|
|
26
|
+
.action(async (options) => {
|
|
27
|
+
try {
|
|
28
|
+
logger.info('Initializing Docula...');
|
|
29
|
+
const docula = new Docula(options);
|
|
30
|
+
await docula.init();
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
reportError(error);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
program.command('serve')
|
|
37
|
+
.description('build and serve the site')
|
|
38
|
+
.action(async (options) => {
|
|
39
|
+
try {
|
|
40
|
+
logger.info('Building your documentation...');
|
|
41
|
+
const docula = new Docula(options);
|
|
42
|
+
await docula.build();
|
|
43
|
+
logger.info('Site was built successfully!');
|
|
44
|
+
await docula.serve();
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
reportError(error);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
program.parse(process.argv);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAoB,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,MAAM,MAAM,aAAa,CAAC;AAMjC,MAAM,OAAO,UAAU;IACtB,gEAAgE;IAChE,KAAK,CAAC,QAAQ,CAAC,OAAuB;QACrC,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;QAEhC,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAEvC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC;aACzC,WAAW,CAAC,gBAAgB,CAAC;aAC7B,MAAM,CAAC,uBAAuB,EAAE,0CAA0C,CAAC;aAC3E,MAAM,CAAC,KAAK,EAAE,OAAyB,EAAE,EAAE;YAC3C,IAAI;gBACH,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;gBAC9C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;gBACnC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;gBACrB,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;aAC5C;YAAC,OAAO,KAAc,EAAE;gBACxB,WAAW,CAAC,KAAK,CAAC,CAAC;aACnB;QACF,CAAC,CAAC,CAAC;QAEJ,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;aACrB,WAAW,CAAC,qBAAqB,CAAC;aAClC,MAAM,CAAC,KAAK,EAAE,OAAyB,EAAE,EAAE;YAC3C,IAAI;gBACH,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;gBACtC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;gBACnC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;aACpB;YAAC,OAAO,KAAc,EAAE;gBACxB,WAAW,CAAC,KAAK,CAAC,CAAC;aACnB;QACF,CAAC,CAAC,CAAC;QAEJ,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;aACtB,WAAW,CAAC,0BAA0B,CAAC;aACvC,MAAM,CAAC,KAAK,EAAE,OAAyB,EAAE,EAAE;YAC3C,IAAI;gBACH,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;gBAC9C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;gBACnC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;gBACrB,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;gBAC5C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;aACrB;YAAC,OAAO,KAAc,EAAE;gBACxB,WAAW,CAAC,KAAK,CAAC,CAAC;aACnB;QACF,CAAC,CAAC,CAAC;QAEJ,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import {createCommand, type OptionValues} from 'commander';\nimport {Docula} from './docula.js';\nimport {reportError} from './tools/tools.js';\nimport logger from './logger.js';\n\nexport type CommanderOptions = {\n\topts: () => OptionValues;\n};\n\nexport class Executable {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tasync parseCLI(process: NodeJS.Process) {\n\t\tconst program = createCommand();\n\n\t\tprogram.storeOptionsAsProperties(true);\n\n\t\tprogram.command('build', {isDefault: true})\n\t\t\t.description('Build the site')\n\t\t\t.option('-c, --config <config>', 'Path of where the config file is located')\n\t\t\t.action(async (options: CommanderOptions) => {\n\t\t\t\ttry {\n\t\t\t\t\tlogger.info('Building your documentation...');\n\t\t\t\t\tconst docula = new Docula(options);\n\t\t\t\t\tawait docula.build();\n\t\t\t\t\tlogger.info('Site was built successfully!');\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\treportError(error);\n\t\t\t\t}\n\t\t\t});\n\n\t\tprogram.command('init')\n\t\t\t.description('Initialize the site')\n\t\t\t.action(async (options: CommanderOptions) => {\n\t\t\t\ttry {\n\t\t\t\t\tlogger.info('Initializing Docula...');\n\t\t\t\t\tconst docula = new Docula(options);\n\t\t\t\t\tawait docula.init();\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\treportError(error);\n\t\t\t\t}\n\t\t\t});\n\n\t\tprogram.command('serve')\n\t\t\t.description('build and serve the site')\n\t\t\t.action(async (options: CommanderOptions) => {\n\t\t\t\ttry {\n\t\t\t\t\tlogger.info('Building your documentation...');\n\t\t\t\t\tconst docula = new Docula(options);\n\t\t\t\t\tawait docula.build();\n\t\t\t\t\tlogger.info('Site was built successfully!');\n\t\t\t\t\tawait docula.serve();\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\treportError(error);\n\t\t\t\t}\n\t\t\t});\n\n\t\tprogram.parse(process.argv);\n\t}\n}\n"]}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAU9B,QAAA,MAAM,MAAM,gBAaV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import winston from 'winston';
|
|
2
|
+
const logFormat = winston.format.printf(({ level, message }) => {
|
|
3
|
+
if (level === 'error') {
|
|
4
|
+
return `[Docula] Error: ${message}`;
|
|
5
|
+
}
|
|
6
|
+
return `[Docula] ${message}`;
|
|
7
|
+
});
|
|
8
|
+
const logger = winston.createLogger({
|
|
9
|
+
level: 'info',
|
|
10
|
+
format: winston.format.json(),
|
|
11
|
+
transports: [
|
|
12
|
+
new winston.transports.Console({
|
|
13
|
+
format: winston.format.combine(logFormat, winston.format.colorize({
|
|
14
|
+
all: true,
|
|
15
|
+
})),
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
export default logger;
|
|
20
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAC,KAAK,EAAE,OAAO,EAAyB,EAAE,EAAE;IACpF,IAAI,KAAK,KAAK,OAAO,EAAE;QACtB,OAAO,mBAAmB,OAAO,EAAE,CAAC;KACpC;IAED,OAAO,YAAY,OAAO,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACnC,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE;IAC7B,UAAU,EAAE;QACX,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAC7B,SAAS,EACT,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACvB,GAAG,EAAE,IAAI;aACT,CAAC,CACF;SACD,CAAC;KACF;CACD,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC","sourcesContent":["import winston from 'winston';\n\nconst logFormat = winston.format.printf(({level, message}: Record<string, string>) => {\n\tif (level === 'error') {\n\t\treturn `[Docula] Error: ${message}`;\n\t}\n\n\treturn `[Docula] ${message}`;\n});\n\nconst logger = winston.createLogger({\n\tlevel: 'info',\n\tformat: winston.format.json(),\n\ttransports: [\n\t\tnew winston.transports.Console({\n\t\t\tformat: winston.format.combine(\n\t\t\t\tlogFormat,\n\t\t\t\twinston.format.colorize({\n\t\t\t\t\tall: true,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t],\n});\n\nexport default logger;\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type SearchClient, type SearchIndex } from 'algoliasearch';
|
|
2
|
+
import type { Config } from '../config.js';
|
|
3
|
+
import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
|
|
4
|
+
export type AlgoliaConfig = {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
appId: string;
|
|
7
|
+
indexName: string;
|
|
8
|
+
};
|
|
9
|
+
type SearchOptions = {
|
|
10
|
+
index?: SearchIndex;
|
|
11
|
+
} & Options;
|
|
12
|
+
export declare class AlgoliaPlugin implements DoculaPlugin {
|
|
13
|
+
static schema: Schema;
|
|
14
|
+
readonly options: SearchOptions;
|
|
15
|
+
runtime: Runtime;
|
|
16
|
+
readonly client: SearchClient;
|
|
17
|
+
constructor(config: Config);
|
|
18
|
+
execute(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=algolia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algolia.d.ts","sourceRoot":"","sources":["../../src/plugins/algolia.ts"],"names":[],"mappings":"AACA,OAAsB,EAAC,KAAK,YAAY,EAAE,KAAK,WAAW,EAAC,MAAM,eAAe,CAAC;AAEjF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAEhF,MAAM,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,aAAa,GAAG;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB,GAAG,OAAO,CAAC;AAEZ,qBAAa,aAAc,YAAW,YAAY;IACjD,MAAM,CAAC,MAAM,EAAE,MAAM,CAQnB;IAEF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAK7B;IAEF,OAAO,EAAE,OAAO,CAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;gBAElB,MAAM,EAAE,MAAM;IAWpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAqB9B"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import algoliasearch from 'algoliasearch';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
export class AlgoliaPlugin {
|
|
5
|
+
static schema = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
required: ['apiKey', 'appId', 'indexName'],
|
|
8
|
+
properties: {
|
|
9
|
+
apiKey: { type: 'string' },
|
|
10
|
+
appId: { type: 'string' },
|
|
11
|
+
indexName: { type: 'string' },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
options = {
|
|
15
|
+
apiKey: '',
|
|
16
|
+
appId: '',
|
|
17
|
+
indexName: '',
|
|
18
|
+
outputPath: '',
|
|
19
|
+
};
|
|
20
|
+
runtime = 'after';
|
|
21
|
+
client;
|
|
22
|
+
constructor(config) {
|
|
23
|
+
const { appId, apiKey, indexName } = config.pluginConfig.algolia;
|
|
24
|
+
this.options.outputPath = config.outputPath;
|
|
25
|
+
this.options.appId = appId;
|
|
26
|
+
this.options.apiKey = apiKey;
|
|
27
|
+
this.options.indexName = indexName;
|
|
28
|
+
// @ts-expect-error - algoliasearch is not callable
|
|
29
|
+
this.client = algoliasearch(this.options.appId, this.options.apiKey);
|
|
30
|
+
this.options.index = this.client.initIndex(this.options.indexName);
|
|
31
|
+
}
|
|
32
|
+
async execute() {
|
|
33
|
+
let jsonContent = [];
|
|
34
|
+
const jsonPath = `${process.cwd()}/${this.options.outputPath}/algolia.json`;
|
|
35
|
+
if (fs.existsSync(jsonPath)) {
|
|
36
|
+
const data = fs.readFileSync(jsonPath, 'utf8');
|
|
37
|
+
const content = JSON.parse(data);
|
|
38
|
+
jsonContent = content.filter(item => item.description.length);
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
// @ts-expect-error - clearObjects
|
|
42
|
+
await this.options.index.clearObjects();
|
|
43
|
+
// @ts-expect-error - saveObjects
|
|
44
|
+
await this.options.index.saveObjects(jsonContent, {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
46
|
+
autoGenerateObjectIDIfNotExist: true,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new Error(`Error while indexing to Algolia: ${error.message}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=algolia.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algolia.js","sourceRoot":"","sources":["../../src/plugins/algolia.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,aAAoD,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,MAAM,UAAU,CAAC;AAc1B,MAAM,OAAO,aAAa;IACzB,MAAM,CAAC,MAAM,GAAW;QACvB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC;QAC1C,UAAU,EAAE;YACX,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;YACxB,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;YACvB,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;SAC3B;KACD,CAAC;IAEO,OAAO,GAAkB;QACjC,MAAM,E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SAC9D;QAED,IAAI;YACH,kCAAkC;YAClC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;YACxC,iCAAiC;YACjC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE;gBACjD,gEAAgE;gBAChE,8BAA8B,EAAE,IAAI;aACpC,CAAC,CAAC;SACH;QAAC,OAAO,KAAc,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,oCAAqC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;SAChF;IACF,CAAC","sourcesContent":["import process from 'node:process';\nimport algoliasearch, {type SearchClient, type SearchIndex} from 'algoliasearch';\nimport fs from 'fs-extra';\nimport type {Config} from '../config.js';\nimport type {DoculaPlugin, Options, Schema, Runtime} from '../docula-plugin.js';\n\nexport type AlgoliaConfig = {\n\tapiKey: string;\n\tappId: string;\n\tindexName: string;\n};\n\ntype SearchOptions = {\n\tindex?: SearchIndex;\n} & Options;\n\nexport class AlgoliaPlugin implements DoculaPlugin {\n\tstatic schema: Schema = {\n\t\ttype: 'object',\n\t\trequired: ['apiKey', 'appId', 'indexName'],\n\t\tproperties: {\n\t\t\tapiKey: {type: 'string'},\n\t\t\tappId: {type: 'string'},\n\t\t\tindexName: {type: 'string'},\n\t\t},\n\t};\n\n\treadonly options: SearchOptions = {\n\t\tapiKey: '',\n\t\tappId: '',\n\t\tindexName: '',\n\t\toutputPath: '',\n\t};\n\n\truntime: Runtime = 'after';\n\treadonly client: SearchClient;\n\n\tconstructor(config: Config) {\n\t\tconst {appId, apiKey, indexName} = config.pluginConfig.algolia as AlgoliaConfig;\n\t\tthis.options.outputPath = config.outputPath;\n\t\tthis.options.appId = appId;\n\t\tthis.options.apiKey = apiKey;\n\t\tthis.options.indexName = indexName;\n\t\t// @ts-expect-error - algoliasearch is not callable\n\t\tthis.client = algoliasearch(this.options.appId, this.options.apiKey);\n\t\tthis.options.index = this.client.initIndex(this.options.indexName);\n\t}\n\n\tasync execute(): Promise<void> {\n\t\tlet jsonContent: Array<Record<string, string>> = [];\n\t\tconst jsonPath = `${process.cwd()}/${this.options.outputPath}/algolia.json`;\n\t\tif (fs.existsSync(jsonPath)) {\n\t\t\tconst data = fs.readFileSync(jsonPath, 'utf8');\n\t\t\tconst content: Array<Record<string, string>> = JSON.parse(data);\n\t\t\tjsonContent = content.filter(item => item.description.length);\n\t\t}\n\n\t\ttry {\n\t\t\t// @ts-expect-error - clearObjects\n\t\t\tawait this.options.index.clearObjects();\n\t\t\t// @ts-expect-error - saveObjects\n\t\t\tawait this.options.index.saveObjects(jsonContent, {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\t\t\t\tautoGenerateObjectIDIfNotExist: true,\n\t\t\t});\n\t\t} catch (error: unknown) {\n\t\t\tthrow new Error(`Error while indexing to Algolia: ${(error as Error).message}`);\n\t\t}\n\t}\n}\n\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
|
|
2
|
+
import type { Config } from '../config.js';
|
|
3
|
+
export type GithubConfig = {
|
|
4
|
+
repo: string;
|
|
5
|
+
author: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class GithubPlugin implements DoculaPlugin {
|
|
8
|
+
static schema: Schema;
|
|
9
|
+
readonly options: Options;
|
|
10
|
+
runtime: Runtime;
|
|
11
|
+
constructor(config: Config);
|
|
12
|
+
execute(): Promise<void>;
|
|
13
|
+
getReleases(): Promise<any>;
|
|
14
|
+
getContributors(): Promise<any>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/plugins/github.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,YAAa,YAAW,YAAY;IAChD,MAAM,CAAC,MAAM,EAAE,MAAM,CAOnB;IAEF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAOvB;IAEF,OAAO,EAAE,OAAO,CAAY;gBAEhB,MAAM,EAAE,MAAM;IAOpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAaxB,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAe3B,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAcrC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
export class GithubPlugin {
|
|
4
|
+
static schema = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
required: ['repo', 'author'],
|
|
7
|
+
properties: {
|
|
8
|
+
repo: { type: 'string' },
|
|
9
|
+
author: { type: 'string' },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
options = {
|
|
13
|
+
api: 'https://api.github.com',
|
|
14
|
+
dataPath: '_data',
|
|
15
|
+
author: '',
|
|
16
|
+
repo: '',
|
|
17
|
+
outputFile: 'github.json',
|
|
18
|
+
sitePath: '',
|
|
19
|
+
};
|
|
20
|
+
runtime = 'before';
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.options.sitePath = config.originPath;
|
|
23
|
+
const { author, repo } = config.pluginConfig.github;
|
|
24
|
+
this.options.author = author;
|
|
25
|
+
this.options.repo = repo;
|
|
26
|
+
}
|
|
27
|
+
async execute() {
|
|
28
|
+
const data = {
|
|
29
|
+
releases: {},
|
|
30
|
+
contributors: {},
|
|
31
|
+
};
|
|
32
|
+
data.releases = await this.getReleases();
|
|
33
|
+
data.contributors = await this.getContributors();
|
|
34
|
+
const path = `${this.options.sitePath}/${this.options.dataPath}`;
|
|
35
|
+
const filePath = `${path}/${this.options.outputFile}`;
|
|
36
|
+
await fs.ensureDir(path);
|
|
37
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2));
|
|
38
|
+
}
|
|
39
|
+
async getReleases() {
|
|
40
|
+
const url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/releases`;
|
|
41
|
+
try {
|
|
42
|
+
const result = await axios.get(url);
|
|
43
|
+
return result.data;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const typedError = error;
|
|
47
|
+
if (typedError.response?.status === 404) {
|
|
48
|
+
throw new Error(`Repository ${this.options.author}/${this.options.repo} not found.`);
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async getContributors() {
|
|
54
|
+
const url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/contributors`;
|
|
55
|
+
try {
|
|
56
|
+
const result = await axios.get(url);
|
|
57
|
+
return result.data;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const typedError = error;
|
|
61
|
+
if (typedError.response?.status === 404) {
|
|
62
|
+
throw new Error(`Repository ${this.options.author}/${this.options.repo} not found.`);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/plugins/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,MAAM,OAAO,YAAY;IACxB,MAAM,CAAC,MAAM,GAAW;QACvB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;QAC5B,UAAU,EAAE;YACX,IAAI,E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, Runtime} from '../docula-plugin.js';\nimport type {Config} from '../config.js';\n\nexport type GithubConfig = {\n\trepo: string;\n\tauthor: string;\n};\n\nexport class GithubPlugin implements DoculaPlugin {\n\tstatic schema: Schema = {\n\t\ttype: 'object',\n\t\trequired: ['repo', 'author'],\n\t\tproperties: {\n\t\t\trepo: {type: 'string'},\n\t\t\tauthor: {type: 'string'},\n\t\t},\n\t};\n\n\treadonly options: Options = {\n\t\tapi: 'https://api.github.com',\n\t\tdataPath: '_data',\n\t\tauthor: '',\n\t\trepo: '',\n\t\toutputFile: 'github.json',\n\t\tsitePath: '',\n\t};\n\n\truntime: Runtime = 'before';\n\n\tconstructor(config: Config) {\n\t\tthis.options.sitePath = config.originPath;\n\t\tconst {author, repo} = config.pluginConfig.github as GithubConfig;\n\t\tthis.options.author = author;\n\t\tthis.options.repo = repo;\n\t}\n\n\tasync execute(): Promise<void> {\n\t\tconst data = {\n\t\t\treleases: {},\n\t\t\tcontributors: {},\n\t\t};\n\t\tdata.releases = await this.getReleases();\n\t\tdata.contributors = await this.getContributors();\n\t\tconst path = `${this.options.sitePath}/${this.options.dataPath}`;\n\t\tconst filePath = `${path}/${this.options.outputFile}`;\n\t\tawait fs.ensureDir(path);\n\t\tawait fs.writeFile(filePath, JSON.stringify(data, null, 2));\n\t}\n\n\tasync getReleases(): Promise<any> {\n\t\tconst url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/releases`;\n\t\ttry {\n\t\t\tconst result = await axios.get(url);\n\t\t\treturn result.data;\n\t\t} catch (error: unknown) {\n\t\t\tconst typedError = error as {response: {status: number}};\n\t\t\tif (typedError.response?.status === 404) {\n\t\t\t\tthrow new Error(`Repository ${this.options.author}/${this.options.repo} not found.`);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync getContributors(): Promise<any> {\n\t\tconst url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/contributors`;\n\t\ttry {\n\t\t\tconst result = await axios.get(url);\n\t\t\treturn result.data;\n\t\t} catch (error: unknown) {\n\t\t\tconst typedError = error as {response: {status: number}};\n\t\t\tif (typedError.response?.status === 404) {\n\t\t\t\tthrow new Error(`Repository ${this.options.author}/${this.options.repo} not found.`);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type GithubConfig, GithubPlugin } from './github.js';
|
|
2
|
+
import { type NpmConfig, NpmPlugin } from './npm.js';
|
|
3
|
+
import { type RobotsConfig, RobotsPlugin } from './robots.js';
|
|
4
|
+
import { SitemapPlugin } from './sitemap.js';
|
|
5
|
+
import { PagefindPlugin } from './pagefind.js';
|
|
6
|
+
import { type AlgoliaConfig, AlgoliaPlugin } from './algolia.js';
|
|
7
|
+
declare const plugins: {
|
|
8
|
+
github: typeof GithubPlugin;
|
|
9
|
+
npm: typeof NpmPlugin;
|
|
10
|
+
robots: typeof RobotsPlugin;
|
|
11
|
+
sitemap: typeof SitemapPlugin;
|
|
12
|
+
pagefind: typeof PagefindPlugin;
|
|
13
|
+
algolia: typeof AlgoliaPlugin;
|
|
14
|
+
};
|
|
15
|
+
export type PluginConfig = GithubConfig | NpmConfig | RobotsConfig | AlgoliaConfig;
|
|
16
|
+
export type PluginInstance = GithubPlugin | NpmPlugin | RobotsPlugin | SitemapPlugin | PagefindPlugin | AlgoliaPlugin;
|
|
17
|
+
export default plugins;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,YAAY,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAC,KAAK,SAAS,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,KAAK,YAAY,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,KAAK,aAAa,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAE/D,QAAA,MAAM,OAAO;;;;;;;CAOZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,aAAa,CAAC;AAEnF,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC;AAEtH,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GithubPlugin } from './github.js';
|
|
2
|
+
import { NpmPlugin } from './npm.js';
|
|
3
|
+
import { RobotsPlugin } from './robots.js';
|
|
4
|
+
import { SitemapPlugin } from './sitemap.js';
|
|
5
|
+
import { PagefindPlugin } from './pagefind.js';
|
|
6
|
+
import { AlgoliaPlugin } from './algolia.js';
|
|
7
|
+
const plugins = {
|
|
8
|
+
github: GithubPlugin,
|
|
9
|
+
npm: NpmPlugin,
|
|
10
|
+
robots: RobotsPlugin,
|
|
11
|
+
sitemap: SitemapPlugin,
|
|
12
|
+
pagefind: PagefindPlugin,
|
|
13
|
+
algolia: AlgoliaPlugin,
|
|
14
|
+
};
|
|
15
|
+
export default plugins;
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAiB,SAAS,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAoB,YAAY,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAqB,aAAa,EAAC,MAAM,cAAc,CAAC;AAE/D,MAAM,OAAO,GAAG;IACf,MAAM,EAAE,YAAY;IACpB,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,cAAc;IACxB,OAAO,EAAE,aAAa;CACtB,CAAC;AAMF,eAAe,OAAO,CAAC","sourcesContent":["import {type GithubConfig, GithubPlugin} from './github.js';\nimport {type NpmConfig, NpmPlugin} from './npm.js';\nimport {type RobotsConfig, RobotsPlugin} from './robots.js';\nimport {SitemapPlugin} from './sitemap.js';\nimport {PagefindPlugin} from './pagefind.js';\nimport {type AlgoliaConfig, AlgoliaPlugin} from './algolia.js';\n\nconst plugins = {\n\tgithub: GithubPlugin,\n\tnpm: NpmPlugin,\n\trobots: RobotsPlugin,\n\tsitemap: SitemapPlugin,\n\tpagefind: PagefindPlugin,\n\talgolia: AlgoliaPlugin,\n};\n\nexport type PluginConfig = GithubConfig | NpmConfig | RobotsConfig | AlgoliaConfig;\n\nexport type PluginInstance = GithubPlugin | NpmPlugin | RobotsPlugin | SitemapPlugin | PagefindPlugin | AlgoliaPlugin;\n\nexport default plugins;\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
|
|
2
|
+
import type { Config } from '../config.js';
|
|
3
|
+
export type NpmConfig = {
|
|
4
|
+
moduleName: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class NpmPlugin implements DoculaPlugin {
|
|
7
|
+
static schema: Schema;
|
|
8
|
+
readonly options: Options;
|
|
9
|
+
runtime: Runtime;
|
|
10
|
+
constructor(config: Config);
|
|
11
|
+
execute(): Promise<void>;
|
|
12
|
+
getMonthlyDownloads(): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=npm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../src/plugins/npm.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,qBAAa,SAAU,YAAW,YAAY;IAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnB;IAEF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAKvB;IAEF,OAAO,EAAE,OAAO,CAAY;gBAEhB,MAAM,EAAE,MAAM;IAMpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQxB,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC;CAKzC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
export class NpmPlugin {
|
|
4
|
+
static schema = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
required: ['moduleName'],
|
|
7
|
+
properties: {
|
|
8
|
+
moduleName: { type: 'string' },
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
options = {
|
|
12
|
+
dataPath: '_data',
|
|
13
|
+
moduleName: '',
|
|
14
|
+
outputFile: 'npm.json',
|
|
15
|
+
sitePath: '',
|
|
16
|
+
};
|
|
17
|
+
runtime = 'before';
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.options.sitePath = config.originPath;
|
|
20
|
+
const { moduleName } = config.pluginConfig.npm;
|
|
21
|
+
this.options.moduleName = moduleName;
|
|
22
|
+
}
|
|
23
|
+
async execute() {
|
|
24
|
+
const data = await this.getMonthlyDownloads();
|
|
25
|
+
const path = `${this.options.sitePath}/${this.options.dataPath}`;
|
|
26
|
+
const filePath = `${this.options.sitePath}/${this.options.dataPath}/${this.options.outputFile}`;
|
|
27
|
+
await fs.ensureDir(path);
|
|
28
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2));
|
|
29
|
+
}
|
|
30
|
+
async getMonthlyDownloads() {
|
|
31
|
+
const url = `https://api.npmjs.org/downloads/point/last-month/${this.options.moduleName}`;
|
|
32
|
+
const result = await axios.get(url);
|
|
33
|
+
return result.data;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=npm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.js","sourceRoot":"","sources":["../../src/plugins/npm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,UAAU,CAAC;AAQ1B,MAAM,OAAO,SAAS;IACrB,MAAM,CAAC,MAAM,GAAW;QACvB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,YAAY,CAAC;QACxB,UAAU,EAAE;YACX,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;SAC5B;KACD,CAAC;IAEO,OAAO,GAAY;QAC3B,QAAQ,EAAE,OAAO;QACjB,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,EAAE;KACZ,CAAC;IAEF,OAAO,GAAY,QAAQ,CAAC;IAE5B,YAAY,MAAc;QACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;QAC1C,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,CAAC,YAAY,CAAC,GAAgB,CAAC;QAC1D,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACjE,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAChG,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,mBAAmB;QACxB,MAAM,GAAG,GAAG,oDAAoD,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC1F,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC;IACpB,CAAC","sourcesContent":["import axios from 'axios';\nimport fs from 'fs-extra';\nimport type {DoculaPlugin, Options, Schema, Runtime} from '../docula-plugin.js';\nimport type {Config} from '../config.js';\n\nexport type NpmConfig = {\n\tmoduleName: string;\n};\n\nexport class NpmPlugin implements DoculaPlugin {\n\tstatic schema: Schema = {\n\t\ttype: 'object',\n\t\trequired: ['moduleName'],\n\t\tproperties: {\n\t\t\tmoduleName: {type: 'string'},\n\t\t},\n\t};\n\n\treadonly options: Options = {\n\t\tdataPath: '_data',\n\t\tmoduleName: '',\n\t\toutputFile: 'npm.json',\n\t\tsitePath: '',\n\t};\n\n\truntime: Runtime = 'before';\n\n\tconstructor(config: Config) {\n\t\tthis.options.sitePath = config.originPath;\n\t\tconst {moduleName} = config.pluginConfig.npm as NpmConfig;\n\t\tthis.options.moduleName = moduleName;\n\t}\n\n\tasync execute(): Promise<void> {\n\t\tconst data = await this.getMonthlyDownloads();\n\t\tconst path = `${this.options.sitePath}/${this.options.dataPath}`;\n\t\tconst filePath = `${this.options.sitePath}/${this.options.dataPath}/${this.options.outputFile}`;\n\t\tawait fs.ensureDir(path);\n\t\tawait fs.writeFile(filePath, JSON.stringify(data, null, 2));\n\t}\n\n\tasync getMonthlyDownloads(): Promise<any> {\n\t\tconst url = `https://api.npmjs.org/downloads/point/last-month/${this.options.moduleName}`;\n\t\tconst result = await axios.get(url);\n\t\treturn result.data;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
|
|
2
|
+
import type { Config } from '../config.js';
|
|
3
|
+
export declare class PagefindPlugin implements DoculaPlugin {
|
|
4
|
+
static schema: Schema;
|
|
5
|
+
readonly options: Options;
|
|
6
|
+
runtime: Runtime;
|
|
7
|
+
constructor(config: Config);
|
|
8
|
+
execute(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=pagefind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagefind.d.ts","sourceRoot":"","sources":["../../src/plugins/pagefind.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,qBAAa,cAAe,YAAW,YAAY;IAClD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAE3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAEvB;IAEF,OAAO,EAAE,OAAO,CAAW;gBAEf,MAAM,EAAE,MAAM;IAIpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAW9B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { exec } from 'node:child_process';
|
|
2
|
+
export class PagefindPlugin {
|
|
3
|
+
static schema = {};
|
|
4
|
+
options = {
|
|
5
|
+
outputPath: '',
|
|
6
|
+
};
|
|
7
|
+
runtime = 'after';
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.options.outputPath = config.outputPath;
|
|
10
|
+
}
|
|
11
|
+
async execute() {
|
|
12
|
+
await new Promise((resolve, reject) => {
|
|
13
|
+
exec(`npx pagefind --source ${this.options.outputPath}`, (error, stdout) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
}
|
|
17
|
+
resolve(stdout);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=pagefind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagefind.js","sourceRoot":"","sources":["../../src/plugins/pagefind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAIxC,MAAM,OAAO,cAAc;IAC1B,MAAM,CAAC,MAAM,GAAW,EAAE,CAAC;IAElB,OAAO,GAAY;QAC3B,UAAU,EAAE,EAAE;KACd,CAAC;IAEF,OAAO,GAAY,OAAO,CAAC;IAE3B,YAAY,MAAc;QACzB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,yBAAyB,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,KAAU,EAAE,MAAW,EAAE,EAAE;gBACpF,IAAI,KAAK,EAAE;oBACV,MAAM,CAAC,KAAK,CAAC,CAAC;iBACd;gBAED,OAAO,CAAC,MAAM,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC","sourcesContent":["import {exec} from 'node:child_process';\nimport type {DoculaPlugin, Options, Schema, Runtime} from '../docula-plugin.js';\nimport type {Config} from '../config.js';\n\nexport class PagefindPlugin implements DoculaPlugin {\n\tstatic schema: Schema = {};\n\n\treadonly options: Options = {\n\t\toutputPath: '',\n\t};\n\n\truntime: Runtime = 'after';\n\n\tconstructor(config: Config) {\n\t\tthis.options.outputPath = config.outputPath;\n\t}\n\n\tasync execute(): Promise<void> {\n\t\tawait new Promise((resolve, reject) => {\n\t\t\texec(`npx pagefind --source ${this.options.outputPath}`, (error: any, stdout: any) => {\n\t\t\t\tif (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\n\t\t\t\tresolve(stdout);\n\t\t\t});\n\t\t});\n\t}\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DoculaPlugin, Options, Runtime, Schema } from '../docula-plugin.js';
|
|
2
|
+
import type { Config } from '../config.js';
|
|
3
|
+
export type RobotsConfig = {
|
|
4
|
+
allowedUrl: string;
|
|
5
|
+
disallowedUrl: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class RobotsPlugin implements DoculaPlugin {
|
|
8
|
+
static schema: Schema;
|
|
9
|
+
readonly options: Options;
|
|
10
|
+
runtime: Runtime;
|
|
11
|
+
constructor(config: Config);
|
|
12
|
+
execute(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=robots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robots.d.ts","sourceRoot":"","sources":["../../src/plugins/robots.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,qBAAa,YAAa,YAAW,YAAY;IAChD,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnB;IAEF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAGvB;IAEF,OAAO,EAAE,OAAO,CAAW;gBAEf,MAAM,EAAE,MAAM;IAYpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAS9B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
export class RobotsPlugin {
|
|
3
|
+
static schema = {
|
|
4
|
+
type: 'object',
|
|
5
|
+
properties: {
|
|
6
|
+
allowedUrl: { type: 'string' },
|
|
7
|
+
disallowedUrl: { type: 'string' },
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
options = {
|
|
11
|
+
sitemapPath: 'sitemap.xml',
|
|
12
|
+
outputFile: 'robots.txt',
|
|
13
|
+
};
|
|
14
|
+
runtime = 'after';
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.options.outputPath = config.outputPath;
|
|
17
|
+
const { allowedUrl, disallowedUrl } = config.pluginConfig.robots || {};
|
|
18
|
+
if (allowedUrl) {
|
|
19
|
+
this.options.allowedUrl = allowedUrl;
|
|
20
|
+
}
|
|
21
|
+
if (disallowedUrl) {
|
|
22
|
+
this.options.disallowedUrl = disallowedUrl;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async execute() {
|
|
26
|
+
const isAllowed = this.options.allowedUrl ? `Allow: ${this.options.allowedUrl}` : '';
|
|
27
|
+
const isDisallowed = this.options.disallowedUrl ? `Disallow: ${this.options.disallowedUrl}` : '';
|
|
28
|
+
const data = `User-agent: * \n${isAllowed} \n${isDisallowed} \nSitemap: ${this.options.sitemapPath}`;
|
|
29
|
+
const filePath = `${this.options.outputPath}/${this.options.outputFile}`;
|
|
30
|
+
await fs.ensureDir(this.options.outputPath);
|
|
31
|
+
await fs.writeFile(filePath, data);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=robots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robots.js","sourceRoot":"","sources":["../../src/plugins/robots.ts"],"names":[],"mappings":"AA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AE,CAAC;QACzE,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import fs from 'fs-extra';\nimport type {DoculaPlugin, Options, Runtime, Schema} from '../docula-plugin.js';\nimport type {Config} from '../config.js';\n\nexport type RobotsConfig = {\n\tallowedUrl: string;\n\tdisallowedUrl: string;\n};\n\nexport class RobotsPlugin implements DoculaPlugin {\n\tstatic schema: Schema = {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tallowedUrl: {type: 'string'},\n\t\t\tdisallowedUrl: {type: 'string'},\n\t\t},\n\t};\n\n\treadonly options: Options = {\n\t\tsitemapPath: 'sitemap.xml',\n\t\toutputFile: 'robots.txt',\n\t};\n\n\truntime: Runtime = 'after';\n\n\tconstructor(config: Config) {\n\t\tthis.options.outputPath = config.outputPath;\n\t\tconst {allowedUrl, disallowedUrl} = config.pluginConfig.robots as unknown as RobotsConfig || {};\n\t\tif (allowedUrl) {\n\t\t\tthis.options.allowedUrl = allowedUrl;\n\t\t}\n\n\t\tif (disallowedUrl)\t{\n\t\t\tthis.options.disallowedUrl = disallowedUrl;\n\t\t}\n\t}\n\n\tasync execute(): Promise<void> {\n\t\tconst isAllowed = this.options.allowedUrl ? `Allow: ${this.options.allowedUrl}` : '';\n\t\tconst isDisallowed = this.options.disallowedUrl ? `Disallow: ${this.options.disallowedUrl}` : '';\n\n\t\tconst data = `User-agent: * \\n${isAllowed} \\n${isDisallowed} \\nSitemap: ${this.options.sitemapPath}`;\n\t\tconst filePath = `${this.options.outputPath}/${this.options.outputFile}`;\n\t\tawait fs.ensureDir(this.options.outputPath);\n\t\tawait fs.writeFile(filePath, data);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
|
|
2
|
+
import type { Config } from '../config.js';
|
|
3
|
+
export declare class SitemapPlugin implements DoculaPlugin {
|
|
4
|
+
static schema: Schema;
|
|
5
|
+
readonly options: Options;
|
|
6
|
+
runtime: Runtime;
|
|
7
|
+
private readonly eleventy;
|
|
8
|
+
constructor(config: Config);
|
|
9
|
+
execute(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=sitemap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../src/plugins/sitemap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGzC,qBAAa,aAAc,YAAW,YAAY;IACjD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAE3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAIvB;IAEF,OAAO,EAAE,OAAO,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;gBAExB,MAAM,EAAE,MAAM;IAQpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAS9B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { Eleventy } from '../eleventy.js';
|
|
3
|
+
export class SitemapPlugin {
|
|
4
|
+
static schema = {};
|
|
5
|
+
options = {
|
|
6
|
+
siteUrl: '',
|
|
7
|
+
outputFile: 'sitemap.xml',
|
|
8
|
+
outputPath: '',
|
|
9
|
+
};
|
|
10
|
+
runtime = 'after';
|
|
11
|
+
eleventy;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.eleventy = new Eleventy(config);
|
|
14
|
+
this.options.outputPath = config.outputPath;
|
|
15
|
+
const { siteUrl } = config;
|
|
16
|
+
this.options.siteUrl = siteUrl;
|
|
17
|
+
}
|
|
18
|
+
async execute() {
|
|
19
|
+
const jsonContent = await this.eleventy.toJSON();
|
|
20
|
+
const content = `<?xml version="1.0" encoding="utf-8"?>
|
|
21
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
|
|
22
|
+
${jsonContent.map(item => (`<url><loc>${this.options.siteUrl}${item.url}</loc></url>`)).join('')}
|
|
23
|
+
</urlset>`;
|
|
24
|
+
fs.writeFileSync(`${this.options.outputPath}/${this.options.outputFile}`, content);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=sitemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.js","sourceRoot":"","sources":["../../src/plugins/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAG1B,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,MAAM,OAAO,aAAa;IACzB,MAAM,CAAC,MAAM,GAAW,EAAE,CAAC;IAElB,OAAO,GAAY;QAC3B,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,EAAE;KACd,CAAC;IAEF,OAAO,GAAY,OAAO,CAAC;IACV,QAAQ,CAAW;IAEpC,YAAY,MAAc;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAC5C,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,CAAC;QAEzB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG;;QAEV,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,aAAa,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;cACxF,CAAC;QAEb,EAAE,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC","sourcesContent":["import fs from 'fs-extra';\nimport type {DoculaPlugin, Options, Schema, Runtime} from '../docula-plugin.js';\nimport type {Config} from '../config.js';\nimport {Eleventy} from '../eleventy.js';\n\nexport class SitemapPlugin implements DoculaPlugin {\n\tstatic schema: Schema = {};\n\n\treadonly options: Options = {\n\t\tsiteUrl: '',\n\t\toutputFile: 'sitemap.xml',\n\t\toutputPath: '',\n\t};\n\n\truntime: Runtime = 'after';\n\tprivate readonly eleventy: Eleventy;\n\n\tconstructor(config: Config) {\n\t\tthis.eleventy = new Eleventy(config);\n\t\tthis.options.outputPath = config.outputPath;\n\t\tconst {siteUrl} = config;\n\n\t\tthis.options.siteUrl = siteUrl;\n\t}\n\n\tasync execute(): Promise<void> {\n\t\tconst jsonContent = await this.eleventy.toJSON();\n\t\tconst content = `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\t\t\t\t<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\" xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\">\n\t\t\t\t ${jsonContent.map(item => (`<url><loc>${this.options.siteUrl}${item.url}</loc></url>`)).join('')}\n\t\t\t\t</urlset>`;\n\n\t\tfs.writeFileSync(`${this.options.outputPath}/${this.options.outputFile}`, content);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Plugins } from './types/config.js';
|
|
2
|
+
type Property = Record<string, string | string[]>;
|
|
3
|
+
type PluginsType = {
|
|
4
|
+
type: string;
|
|
5
|
+
items: {
|
|
6
|
+
type: string;
|
|
7
|
+
enum: Plugins;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type ConfigSchema = {
|
|
11
|
+
type: 'object';
|
|
12
|
+
additionalProperties: boolean;
|
|
13
|
+
properties: {
|
|
14
|
+
[key: string]: Property | PluginsType;
|
|
15
|
+
plugins: PluginsType;
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare const jsonConfigSchema: ConfigSchema;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE/C,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAElD,KAAK,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;KACd,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,oBAAoB,EAAE,OAAO,CAAC;IAC9B,UAAU,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC;QACtC,OAAO,EAAE,WAAW,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,YAsB9B,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import DoculaPlugins from './plugins/index.js';
|
|
2
|
+
export const jsonConfigSchema = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
additionalProperties: false,
|
|
5
|
+
properties: {
|
|
6
|
+
originPath: { type: 'string' },
|
|
7
|
+
outputPath: { type: 'string' },
|
|
8
|
+
dataPath: { type: 'string' },
|
|
9
|
+
templatePath: { type: 'string' },
|
|
10
|
+
searchEngine: { type: 'string', enum: ['algolia', 'pagefind'] },
|
|
11
|
+
plugins: {
|
|
12
|
+
type: 'array',
|
|
13
|
+
items: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
enum: Object.keys(DoculaPlugins),
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
imagesPath: { type: 'string' },
|
|
19
|
+
assetsPath: { type: 'string' },
|
|
20
|
+
siteUrl: { type: 'string' },
|
|
21
|
+
siteType: { type: 'string', enum: ['landing', 'multi page'] },
|
|
22
|
+
},
|
|
23
|
+
required: [],
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAuB/C,MAAM,CAAC,MAAM,gBAAgB,GAAiB;IAC7C,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACX,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,QAAQ,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC1B,YAAY,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC9B,YAAY,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAC;QAC7D,OAAO,EAAE;YACR,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAY;aAC3C;SACD;QACD,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,OAAO,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QACzB,QAAQ,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,EAAC;KAC3D;IACD,QAAQ,EAAE,EAAE;CACZ,CAAC","sourcesContent":["import DoculaPlugins from './plugins/index.js';\nimport {type Plugins} from './types/config.js';\n\ntype Property = Record<string, string | string[]>;\n\ntype PluginsType = {\n\ttype: string;\n\titems: {\n\t\ttype: string;\n\t\tenum: Plugins;\n\t};\n};\n\nexport type ConfigSchema = {\n\ttype: 'object';\n\tadditionalProperties: boolean;\n\tproperties: {\n\t\t[key: string]: Property | PluginsType;\n\t\tplugins: PluginsType;\n\t};\n\trequired: string[];\n};\n\nexport const jsonConfigSchema: ConfigSchema = {\n\ttype: 'object',\n\tadditionalProperties: false,\n\tproperties: {\n\t\toriginPath: {type: 'string'},\n\t\toutputPath: {type: 'string'},\n\t\tdataPath: {type: 'string'},\n\t\ttemplatePath: {type: 'string'},\n\t\tsearchEngine: {type: 'string', enum: ['algolia', 'pagefind']},\n\t\tplugins: {\n\t\t\ttype: 'array',\n\t\t\titems: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: Object.keys(DoculaPlugins) as Plugins,\n\t\t\t},\n\t\t},\n\t\timagesPath: {type: 'string'},\n\t\tassetsPath: {type: 'string'},\n\t\tsiteUrl: {type: 'string'},\n\t\tsiteType: {type: 'string', enum: ['landing', 'multi page']},\n\t},\n\trequired: [],\n};\n"]}
|