fix
This commit is contained in:
11
book/node_modules/honkit/lib/output/website/copyPluginAssets.d.ts
generated
vendored
Normal file
11
book/node_modules/honkit/lib/output/website/copyPluginAssets.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
Copy all assets from plugins.
|
||||
Assets are files stored in "_assets"
|
||||
nd resources declared in the plugin itself.
|
||||
|
||||
@param {Output}
|
||||
@return {Promise}
|
||||
*/
|
||||
declare function copyPluginAssets(output: any): any;
|
||||
export default copyPluginAssets;
|
||||
//# sourceMappingURL=copyPluginAssets.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/copyPluginAssets.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/copyPluginAssets.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"copyPluginAssets.d.ts","sourceRoot":"","sources":["../../../src/output/website/copyPluginAssets.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AAEH,iBAAS,gBAAgB,CAAC,MAAM,KAAA,OAqB/B;AAuED,eAAe,gBAAgB,CAAC"}
|
90
book/node_modules/honkit/lib/output/website/copyPluginAssets.js
generated
vendored
Normal file
90
book/node_modules/honkit/lib/output/website/copyPluginAssets.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const pluginAssetsFolder_1 = __importDefault(require("../../constants/pluginAssetsFolder"));
|
||||
const promise_1 = __importDefault(require("../../utils/promise"));
|
||||
const fs_1 = __importDefault(require("../../utils/fs"));
|
||||
/**
|
||||
Copy all assets from plugins.
|
||||
Assets are files stored in "_assets"
|
||||
nd resources declared in the plugin itself.
|
||||
|
||||
@param {Output}
|
||||
@return {Promise}
|
||||
*/
|
||||
function copyPluginAssets(output) {
|
||||
const book = output.getBook();
|
||||
// Don't copy plugins assets for language book
|
||||
// It'll be resolved to the parent folder
|
||||
if (book.isLanguageBook()) {
|
||||
return (0, promise_1.default)(output);
|
||||
}
|
||||
const plugins = output
|
||||
.getPlugins()
|
||||
// We reverse the order of plugins to copy
|
||||
// so that first plugins can replace assets from other plugins.
|
||||
.reverse();
|
||||
return promise_1.default.forEach(plugins, (plugin) => {
|
||||
return copyAssets(output, plugin).then(() => {
|
||||
return copyResources(output, plugin);
|
||||
});
|
||||
}).thenResolve(output);
|
||||
}
|
||||
/**
|
||||
Copy assets from a plugin
|
||||
|
||||
@param {Plugin}
|
||||
@return {Promise}
|
||||
*/
|
||||
function copyAssets(output, plugin) {
|
||||
const logger = output.getLogger();
|
||||
const pluginRoot = plugin.getPath();
|
||||
const options = output.getOptions();
|
||||
const outputRoot = options.get("root");
|
||||
const assetOutputFolder = path_1.default.join(outputRoot, "gitbook");
|
||||
const prefix = options.get("prefix");
|
||||
const assetFolder = path_1.default.join(pluginRoot, pluginAssetsFolder_1.default, prefix);
|
||||
if (!fs_1.default.existsSync(assetFolder)) {
|
||||
return (0, promise_1.default)();
|
||||
}
|
||||
logger.debug.ln("copy assets from theme", assetFolder);
|
||||
return fs_1.default.copyDir(assetFolder, assetOutputFolder, {
|
||||
deleteFirst: false,
|
||||
overwrite: true,
|
||||
confirm: false
|
||||
});
|
||||
}
|
||||
/**
|
||||
Copy resources from a plugin
|
||||
@return {Promise}
|
||||
*/
|
||||
function copyResources(output, plugin) {
|
||||
const logger = output.getLogger();
|
||||
const options = output.getOptions();
|
||||
const outputRoot = options.get("root");
|
||||
const state = output.getState();
|
||||
const resources = state.getResources();
|
||||
const pluginRoot = plugin.getPath();
|
||||
const pluginResources = resources.get(plugin.getName());
|
||||
let assetsFolder = pluginResources.get("assets");
|
||||
const assetOutputFolder = path_1.default.join(outputRoot, "gitbook", plugin.getNpmID());
|
||||
if (!assetsFolder) {
|
||||
return (0, promise_1.default)();
|
||||
}
|
||||
// Resolve assets folder
|
||||
assetsFolder = path_1.default.resolve(pluginRoot, assetsFolder);
|
||||
if (!fs_1.default.existsSync(assetsFolder)) {
|
||||
logger.warn.ln(`assets folder for plugin "${plugin.getName()}" doesn't exist`);
|
||||
return (0, promise_1.default)();
|
||||
}
|
||||
logger.debug.ln("copy resources from plugin", assetsFolder);
|
||||
return fs_1.default.copyDir(assetsFolder, assetOutputFolder, {
|
||||
deleteFirst: false,
|
||||
overwrite: true,
|
||||
confirm: false
|
||||
});
|
||||
}
|
||||
exports.default = copyPluginAssets;
|
12
book/node_modules/honkit/lib/output/website/createTemplateEngine.d.ts
generated
vendored
Normal file
12
book/node_modules/honkit/lib/output/website/createTemplateEngine.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import TemplateEngine from "../../models/templateEngine";
|
||||
import Output from "../../models/output";
|
||||
/**
|
||||
* Create templating engine to render themes
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {string} currentFile
|
||||
* @return {TemplateEngine}
|
||||
*/
|
||||
declare function createTemplateEngine(output: Output, currentFile: string): TemplateEngine;
|
||||
export default createTemplateEngine;
|
||||
//# sourceMappingURL=createTemplateEngine.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/createTemplateEngine.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/createTemplateEngine.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"createTemplateEngine.d.ts","sourceRoot":"","sources":["../../../src/output/website/createTemplateEngine.ts"],"names":[],"mappings":"AAWA,OAAO,cAAc,MAAM,6BAA6B,CAAC;AAQzD,OAAO,MAAM,MAAM,qBAAqB,CAAC;AASzC;;;;;;GAMG;AAEH,iBAAS,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,CA6HjF;AAED,eAAe,oBAAoB,CAAC"}
|
134
book/node_modules/honkit/lib/output/website/createTemplateEngine.js
generated
vendored
Normal file
134
book/node_modules/honkit/lib/output/website/createTemplateEngine.js
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const nunjucks_1 = __importDefault(require("nunjucks"));
|
||||
const nunjucks_do_1 = __importDefault(require("nunjucks-do"));
|
||||
const DoExtension = (0, nunjucks_do_1.default)(nunjucks_1.default);
|
||||
const memoize_one_1 = __importDefault(require("memoize-one"));
|
||||
const api_1 = __importDefault(require("../../api"));
|
||||
const deprecate_1 = __importDefault(require("../../api/deprecate"));
|
||||
const json_1 = __importDefault(require("../../json"));
|
||||
const location_1 = __importDefault(require("../../utils/location"));
|
||||
const fs_1 = __importDefault(require("../../utils/fs"));
|
||||
const path_2 = __importDefault(require("../../utils/path"));
|
||||
const templateEngine_1 = __importDefault(require("../../models/templateEngine"));
|
||||
const templatesFolder_1 = __importDefault(require("../../constants/templatesFolder"));
|
||||
const defaultFilters_1 = __importDefault(require("../../constants/defaultFilters"));
|
||||
const templating_1 = __importDefault(require("../../templating"));
|
||||
const listSearchPaths_1 = __importDefault(require("./listSearchPaths"));
|
||||
const fileToURL_1 = __importDefault(require("../helper/fileToURL"));
|
||||
const resolveFileToURL_1 = __importDefault(require("../helper/resolveFileToURL"));
|
||||
/**
|
||||
* Directory for a theme with the templates
|
||||
*/
|
||||
function templateFolder(dir) {
|
||||
return path_1.default.join(dir, templatesFolder_1.default);
|
||||
}
|
||||
/**
|
||||
* Create templating engine to render themes
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {string} currentFile
|
||||
* @return {TemplateEngine}
|
||||
*/
|
||||
function createTemplateEngine(output, currentFile) {
|
||||
const book = output.getBook();
|
||||
const state = output.getState();
|
||||
const i18n = state.getI18n();
|
||||
const config = book.getConfig();
|
||||
const summary = book.getSummary();
|
||||
const outputFolder = output.getRoot();
|
||||
// Search paths for templates
|
||||
const searchPaths = (0, listSearchPaths_1.default)(output);
|
||||
const tplSearchPaths = searchPaths.map(templateFolder);
|
||||
// Create loader
|
||||
// @ts-expect-error: Expected 0 arguments, but got 1.
|
||||
const loader = new templating_1.default.ThemesLoader(tplSearchPaths);
|
||||
// Get languages
|
||||
const language = config.getValue("language");
|
||||
// Create API context
|
||||
const context = api_1.default.encodeGlobal(output);
|
||||
/**
|
||||
* Check if a file exists
|
||||
* @param {string} fileName
|
||||
* @return {boolean}
|
||||
*/
|
||||
function fileExists(fileName) {
|
||||
if (!fileName) {
|
||||
return false;
|
||||
}
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 2.
|
||||
const filePath = path_2.default.resolveInRoot(outputFolder, fileName);
|
||||
return fs_1.default.existsSync(filePath);
|
||||
}
|
||||
/**
|
||||
* Return an article by its path
|
||||
* @param {string} filePath
|
||||
* @return {Object|undefined}
|
||||
*/
|
||||
function getArticleByPath(filePath) {
|
||||
const article = summary.getByPath(filePath);
|
||||
if (!article)
|
||||
return undefined;
|
||||
return json_1.default.encodeSummaryArticle(article);
|
||||
}
|
||||
/**
|
||||
* Return a page by its path
|
||||
* @param {string} filePath
|
||||
* @return {Object|undefined}
|
||||
*/
|
||||
function getPageByPath(filePath) {
|
||||
const page = output.getPage(filePath);
|
||||
if (!page)
|
||||
return undefined;
|
||||
return json_1.default.encodePage(page, summary);
|
||||
}
|
||||
return templateEngine_1.default.create({
|
||||
loader: loader,
|
||||
context: context,
|
||||
globals: {
|
||||
getArticleByPath: (0, memoize_one_1.default)(getArticleByPath),
|
||||
getPageByPath: (0, memoize_one_1.default)(getPageByPath),
|
||||
fileExists: fileExists
|
||||
},
|
||||
filters: defaultFilters_1.default.merge({
|
||||
/**
|
||||
* Translate a sentence
|
||||
*/
|
||||
t: function t(s) {
|
||||
return i18n.t(language, s);
|
||||
},
|
||||
/**
|
||||
* Resolve an absolute file path into a
|
||||
* relative path.
|
||||
* it also resolve pages
|
||||
*/
|
||||
resolveFile: function (filePath) {
|
||||
filePath = (0, resolveFileToURL_1.default)(output, filePath);
|
||||
return location_1.default.relativeForFile(currentFile, filePath);
|
||||
},
|
||||
resolveAsset: function (filePath) {
|
||||
filePath = location_1.default.toAbsolute(filePath, "", "");
|
||||
filePath = path_1.default.join("gitbook", filePath);
|
||||
filePath = location_1.default.relativeForFile(currentFile, filePath);
|
||||
// Use assets from parent if language book
|
||||
if (book.isLanguageBook()) {
|
||||
filePath = path_1.default.join("../", filePath);
|
||||
}
|
||||
return location_1.default.normalize(filePath);
|
||||
},
|
||||
fileExists: deprecate_1.default.method(book, "fileExists", fileExists, 'Filter "fileExists" is deprecated, use "fileExists(filename)" '),
|
||||
getArticleByPath: deprecate_1.default.method(book, "getArticleByPath", fileExists, 'Filter "getArticleByPath" is deprecated, use "getArticleByPath(filename)" '),
|
||||
contentURL: function (filePath) {
|
||||
return (0, fileToURL_1.default)(output, filePath);
|
||||
}
|
||||
}),
|
||||
extensions: {
|
||||
DoExtension: new DoExtension()
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.default = createTemplateEngine;
|
18
book/node_modules/honkit/lib/output/website/index.d.ts
generated
vendored
Normal file
18
book/node_modules/honkit/lib/output/website/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
import { onPage } from "./onPage";
|
||||
import { onFinish } from "./onFinish";
|
||||
import GeneratorState from "./state";
|
||||
import onInit0 from "./onInit";
|
||||
import onAsset0 from "./onAsset";
|
||||
import createTemplateEngine0 from "./createTemplateEngine";
|
||||
declare const _default: {
|
||||
name: string;
|
||||
State: typeof GeneratorState;
|
||||
Options: import("immutable").Record.Class;
|
||||
onInit: typeof onInit0;
|
||||
onFinish: typeof onFinish;
|
||||
onPage: typeof onPage;
|
||||
onAsset: typeof onAsset0;
|
||||
createTemplateEngine: typeof createTemplateEngine0;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/index.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/index.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/output/website/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,cAAc,MAAM,SAAS,CAAC;AAErC,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,qBAAqB,MAAM,wBAAwB,CAAC;;;;;;;;;;;AAE3D,wBASE"}
|
22
book/node_modules/honkit/lib/output/website/index.js
generated
vendored
Normal file
22
book/node_modules/honkit/lib/output/website/index.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const onPage_1 = require("./onPage");
|
||||
const onFinish_1 = require("./onFinish");
|
||||
const state_1 = __importDefault(require("./state"));
|
||||
const options_1 = __importDefault(require("./options"));
|
||||
const onInit_1 = __importDefault(require("./onInit"));
|
||||
const onAsset_1 = __importDefault(require("./onAsset"));
|
||||
const createTemplateEngine_1 = __importDefault(require("./createTemplateEngine"));
|
||||
exports.default = {
|
||||
name: "website",
|
||||
State: state_1.default,
|
||||
Options: options_1.default,
|
||||
onInit: onInit_1.default,
|
||||
onFinish: onFinish_1.onFinish,
|
||||
onPage: onPage_1.onPage,
|
||||
onAsset: onAsset_1.default,
|
||||
createTemplateEngine: createTemplateEngine_1.default
|
||||
};
|
9
book/node_modules/honkit/lib/output/website/listSearchPaths.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/output/website/listSearchPaths.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
List search paths for templates / i18n, etc
|
||||
|
||||
@param {Output} output
|
||||
@return {List<String>}
|
||||
*/
|
||||
declare function listSearchPaths(output: any): any;
|
||||
export default listSearchPaths;
|
||||
//# sourceMappingURL=listSearchPaths.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/listSearchPaths.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/listSearchPaths.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"listSearchPaths.d.ts","sourceRoot":"","sources":["../../../src/output/website/listSearchPaths.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iBAAS,eAAe,CAAC,MAAM,KAAA,OAY9B;AAED,eAAe,eAAe,CAAC"}
|
20
book/node_modules/honkit/lib/output/website/listSearchPaths.js
generated
vendored
Normal file
20
book/node_modules/honkit/lib/output/website/listSearchPaths.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
/**
|
||||
List search paths for templates / i18n, etc
|
||||
|
||||
@param {Output} output
|
||||
@return {List<String>}
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function listSearchPaths(output) {
|
||||
const book = output.getBook();
|
||||
const plugins = output.getPlugins();
|
||||
const searchPaths = plugins
|
||||
.valueSeq()
|
||||
.map((plugin) => {
|
||||
return plugin.getPath();
|
||||
})
|
||||
.toList();
|
||||
return searchPaths.unshift(book.getContentRoot());
|
||||
}
|
||||
exports.default = listSearchPaths;
|
9
book/node_modules/honkit/lib/output/website/onAsset.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/output/website/onAsset.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
Copy an asset to the output folder
|
||||
|
||||
@param {Output} output
|
||||
@param {Page} page
|
||||
*/
|
||||
declare function onAsset(output: any, asset: any): any;
|
||||
export default onAsset;
|
||||
//# sourceMappingURL=onAsset.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/onAsset.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/onAsset.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"onAsset.d.ts","sourceRoot":"","sources":["../../../src/output/website/onAsset.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,MAAM,KAAA,EAAE,KAAK,KAAA,OAgB7B;AAED,eAAe,OAAO,CAAC"}
|
29
book/node_modules/honkit/lib/output/website/onAsset.js
generated
vendored
Normal file
29
book/node_modules/honkit/lib/output/website/onAsset.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("../../utils/fs"));
|
||||
/**
|
||||
Copy an asset to the output folder
|
||||
|
||||
@param {Output} output
|
||||
@param {Page} page
|
||||
*/
|
||||
function onAsset(output, asset) {
|
||||
const book = output.getBook();
|
||||
const options = output.getOptions();
|
||||
const bookFS = book.getContentFS();
|
||||
const outputFolder = options.get("root");
|
||||
const outputPath = path_1.default.resolve(outputFolder, asset);
|
||||
return fs_1.default
|
||||
.ensureFile(outputPath)
|
||||
.then(() => {
|
||||
return bookFS.readAsStream(asset).then((stream) => {
|
||||
return fs_1.default.writeStream(outputPath, stream);
|
||||
});
|
||||
})
|
||||
.thenResolve(output);
|
||||
}
|
||||
exports.default = onAsset;
|
9
book/node_modules/honkit/lib/output/website/onFinish.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/output/website/onFinish.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
Finish the generation, write the languages index
|
||||
|
||||
@param {Output} output
|
||||
@return {Output}
|
||||
*/
|
||||
declare function onFinish(output: any): any;
|
||||
export { onFinish };
|
||||
//# sourceMappingURL=onFinish.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/onFinish.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/onFinish.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"onFinish.d.ts","sourceRoot":"","sources":["../../../src/output/website/onFinish.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,iBAAS,QAAQ,CAAC,MAAM,KAAA,OAsBvB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
34
book/node_modules/honkit/lib/output/website/onFinish.js
generated
vendored
Normal file
34
book/node_modules/honkit/lib/output/website/onFinish.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.onFinish = onFinish;
|
||||
const promise_1 = __importDefault(require("../../utils/promise"));
|
||||
const json_1 = __importDefault(require("../../json"));
|
||||
const templating_1 = __importDefault(require("../../templating"));
|
||||
const writeFile_1 = __importDefault(require("../helper/writeFile"));
|
||||
const createTemplateEngine_1 = __importDefault(require("./createTemplateEngine"));
|
||||
/**
|
||||
Finish the generation, write the languages index
|
||||
|
||||
@param {Output} output
|
||||
@return {Output}
|
||||
*/
|
||||
function onFinish(output) {
|
||||
const book = output.getBook();
|
||||
const options = output.getOptions();
|
||||
const prefix = options.get("prefix");
|
||||
if (!book.isMultilingual()) {
|
||||
return (0, promise_1.default)(output);
|
||||
}
|
||||
const filePath = "index.html";
|
||||
const engine = (0, createTemplateEngine_1.default)(output, filePath);
|
||||
const context = json_1.default.encodeOutput(output);
|
||||
// Render the theme
|
||||
return (templating_1.default.renderFile(engine, `${prefix}/languages.html`, context)
|
||||
// Write it to the disk
|
||||
.then((tplOut) => {
|
||||
return (0, writeFile_1.default)(output, filePath, tplOut.getContent());
|
||||
}));
|
||||
}
|
9
book/node_modules/honkit/lib/output/website/onInit.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/output/website/onInit.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
Initialize the generator
|
||||
|
||||
@param {Output}
|
||||
@return {Output}
|
||||
*/
|
||||
declare function onInit(output: any): any;
|
||||
export default onInit;
|
||||
//# sourceMappingURL=onInit.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/onInit.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/onInit.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"onInit.d.ts","sourceRoot":"","sources":["../../../src/output/website/onInit.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,MAAM,KAAA,OAErB;AAED,eAAe,MAAM,CAAC"}
|
19
book/node_modules/honkit/lib/output/website/onInit.js
generated
vendored
Normal file
19
book/node_modules/honkit/lib/output/website/onInit.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const promise_1 = __importDefault(require("../../utils/promise"));
|
||||
const copyPluginAssets_1 = __importDefault(require("./copyPluginAssets"));
|
||||
const prepareI18n_1 = __importDefault(require("./prepareI18n"));
|
||||
const prepareResources_1 = __importDefault(require("./prepareResources"));
|
||||
/**
|
||||
Initialize the generator
|
||||
|
||||
@param {Output}
|
||||
@return {Output}
|
||||
*/
|
||||
function onInit(output) {
|
||||
return (0, promise_1.default)(output).then(prepareI18n_1.default).then(prepareResources_1.default).then(copyPluginAssets_1.default);
|
||||
}
|
||||
exports.default = onInit;
|
9
book/node_modules/honkit/lib/output/website/onPage.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/output/website/onPage.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Write a page as a json file
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {Page} page
|
||||
*/
|
||||
declare function onPage(output: any, page: any): any;
|
||||
export { onPage };
|
||||
//# sourceMappingURL=onPage.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/onPage.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/onPage.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"onPage.d.ts","sourceRoot":"","sources":["../../../src/output/website/onPage.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,MAAM,KAAA,EAAE,IAAI,KAAA,OA4D3B;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
72
book/node_modules/honkit/lib/output/website/onPage.js
generated
vendored
Normal file
72
book/node_modules/honkit/lib/output/website/onPage.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.onPage = onPage;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const omit_keys_1 = __importDefault(require("omit-keys"));
|
||||
const templating_1 = __importDefault(require("../../templating"));
|
||||
const plugins_1 = __importDefault(require("../../plugins"));
|
||||
const json_1 = __importDefault(require("../../json"));
|
||||
const location_1 = __importDefault(require("../../utils/location"));
|
||||
const modifiers_1 = __importDefault(require("../modifiers"));
|
||||
const writeFile_1 = __importDefault(require("../helper/writeFile"));
|
||||
const getModifiers_1 = __importDefault(require("../getModifiers"));
|
||||
const createTemplateEngine_1 = __importDefault(require("./createTemplateEngine"));
|
||||
const fileToOutput_1 = __importDefault(require("../helper/fileToOutput"));
|
||||
/**
|
||||
* Write a page as a json file
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {Page} page
|
||||
*/
|
||||
function onPage(output, page) {
|
||||
const options = output.getOptions();
|
||||
const prefix = options.get("prefix");
|
||||
const file = page.getFile();
|
||||
const book = output.getBook();
|
||||
const plugins = output.getPlugins();
|
||||
const state = output.getState();
|
||||
const resources = state.getResources();
|
||||
const engine = (0, createTemplateEngine_1.default)(output, page.getPath());
|
||||
// Output file path
|
||||
const filePath = (0, fileToOutput_1.default)(output, file.getPath());
|
||||
// Calcul relative path to the root
|
||||
const outputDirName = path_1.default.dirname(filePath);
|
||||
const basePath = location_1.default.normalize(path_1.default.relative(outputDirName, "./"));
|
||||
return modifiers_1.default.modifyHTML(page, (0, getModifiers_1.default)(output, page)).then((resultPage) => {
|
||||
// Generate the context
|
||||
const context = json_1.default.encodeOutputWithPage(output, resultPage);
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'plugins' does not exist on type '{ summa... Remove this comment to see the full error message
|
||||
context.plugins = {
|
||||
resources: plugins_1.default.listResources(plugins, resources).toJS()
|
||||
};
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'template' does not exist on type '{ summ... Remove this comment to see the full error message
|
||||
context.template = {
|
||||
getJSContext: function () {
|
||||
return {
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'page' does not exist on type '{ summary:... Remove this comment to see the full error message
|
||||
page: (0, omit_keys_1.default)(context.page, "content"),
|
||||
config: context.config,
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'file' does not exist on type '{ summary:... Remove this comment to see the full error message
|
||||
file: context.file,
|
||||
gitbook: context.gitbook,
|
||||
basePath: basePath,
|
||||
book: {
|
||||
language: book.getLanguage()
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
// We should probabbly move it to "template" or a "site" namespace
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'basePath' does not exist on type '{ summ... Remove this comment to see the full error message
|
||||
context.basePath = basePath;
|
||||
// Render the theme
|
||||
return (templating_1.default.renderFile(engine, `${prefix}/page.html`, context)
|
||||
// Write it to the disk
|
||||
.then((tplOut) => {
|
||||
return (0, writeFile_1.default)(output, filePath, tplOut.getContent());
|
||||
}));
|
||||
});
|
||||
}
|
4
book/node_modules/honkit/lib/output/website/options.d.ts
generated
vendored
Normal file
4
book/node_modules/honkit/lib/output/website/options.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import Immutable from "immutable";
|
||||
declare const Options: Immutable.Record.Class;
|
||||
export default Options;
|
||||
//# sourceMappingURL=options.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/options.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/options.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/output/website/options.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,QAAA,MAAM,OAAO,wBASX,CAAC;AAEH,eAAe,OAAO,CAAC"}
|
15
book/node_modules/honkit/lib/output/website/options.js
generated
vendored
Normal file
15
book/node_modules/honkit/lib/output/website/options.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const Options = immutable_1.default.Record({
|
||||
// Root folder for the output
|
||||
root: String(),
|
||||
// Prefix for generation
|
||||
prefix: String("website"),
|
||||
// Use directory index url instead of "index.html"
|
||||
directoryIndex: Boolean(true)
|
||||
});
|
||||
exports.default = Options;
|
9
book/node_modules/honkit/lib/output/website/prepareI18n.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/output/website/prepareI18n.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Prepare i18n, load translations from plugins and book
|
||||
*
|
||||
* @param {Output}
|
||||
* @return {Promise<Output>}
|
||||
*/
|
||||
declare function prepareI18n(output: any): any;
|
||||
export default prepareI18n;
|
||||
//# sourceMappingURL=prepareI18n.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/prepareI18n.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/prepareI18n.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"prepareI18n.d.ts","sourceRoot":"","sources":["../../../src/output/website/prepareI18n.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH,iBAAS,WAAW,CAAC,MAAM,KAAA,OAa1B;AAED,eAAe,WAAW,CAAC"}
|
28
book/node_modules/honkit/lib/output/website/prepareI18n.js
generated
vendored
Normal file
28
book/node_modules/honkit/lib/output/website/prepareI18n.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_1 = __importDefault(require("../../utils/fs"));
|
||||
const promise_1 = __importDefault(require("../../utils/promise"));
|
||||
const listSearchPaths_1 = __importDefault(require("./listSearchPaths"));
|
||||
/**
|
||||
* Prepare i18n, load translations from plugins and book
|
||||
*
|
||||
* @param {Output}
|
||||
* @return {Promise<Output>}
|
||||
*/
|
||||
function prepareI18n(output) {
|
||||
const state = output.getState();
|
||||
const i18n = state.getI18n();
|
||||
const searchPaths = (0, listSearchPaths_1.default)(output);
|
||||
searchPaths.reverse().forEach((searchPath) => {
|
||||
const i18nRoot = path_1.default.resolve(searchPath, "_i18n");
|
||||
if (!fs_1.default.existsSync(i18nRoot))
|
||||
return;
|
||||
i18n.load(i18nRoot);
|
||||
});
|
||||
return (0, promise_1.default)(output);
|
||||
}
|
||||
exports.default = prepareI18n;
|
9
book/node_modules/honkit/lib/output/website/prepareResources.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/output/website/prepareResources.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
Prepare plugins resources, add all output corresponding type resources
|
||||
|
||||
@param {Output}
|
||||
@return {Promise<Output>}
|
||||
*/
|
||||
declare function prepareResources(output: any): any;
|
||||
export default prepareResources;
|
||||
//# sourceMappingURL=prepareResources.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/prepareResources.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/prepareResources.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"prepareResources.d.ts","sourceRoot":"","sources":["../../../src/output/website/prepareResources.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH,iBAAS,gBAAgB,CAAC,MAAM,KAAA,OAoC/B;AAED,eAAe,gBAAgB,CAAC"}
|
49
book/node_modules/honkit/lib/output/website/prepareResources.js
generated
vendored
Normal file
49
book/node_modules/honkit/lib/output/website/prepareResources.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const promise_1 = __importDefault(require("../../utils/promise"));
|
||||
const api_1 = __importDefault(require("../../api"));
|
||||
/**
|
||||
Prepare plugins resources, add all output corresponding type resources
|
||||
|
||||
@param {Output}
|
||||
@return {Promise<Output>}
|
||||
*/
|
||||
function prepareResources(output) {
|
||||
const plugins = output.getPlugins();
|
||||
const options = output.getOptions();
|
||||
const type = options.get("prefix");
|
||||
let state = output.getState();
|
||||
const context = api_1.default.encodeGlobal(output);
|
||||
let result = immutable_1.default.Map();
|
||||
return promise_1.default.forEach(plugins, (plugin) => {
|
||||
const pluginResources = plugin.getResources(type);
|
||||
return (0, promise_1.default)()
|
||||
.then(() => {
|
||||
// Apply resources if is a function
|
||||
if (is_1.default.fn(pluginResources)) {
|
||||
return (0, promise_1.default)().then(pluginResources.bind(context));
|
||||
}
|
||||
else {
|
||||
return pluginResources;
|
||||
}
|
||||
})
|
||||
.then((resources) => {
|
||||
result = result.set(plugin.getName(), immutable_1.default.Map(resources));
|
||||
});
|
||||
}).then(() => {
|
||||
// Set output resources
|
||||
state = state.merge({
|
||||
resources: result
|
||||
});
|
||||
output = output.merge({
|
||||
state: state
|
||||
});
|
||||
return output;
|
||||
});
|
||||
}
|
||||
exports.default = prepareResources;
|
10
book/node_modules/honkit/lib/output/website/state.d.ts
generated
vendored
Normal file
10
book/node_modules/honkit/lib/output/website/state.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import I18n from "i18n-t";
|
||||
import Immutable from "immutable";
|
||||
type Resources = Immutable.Map<any, any>;
|
||||
declare const GeneratorState_base: Immutable.Record.Class;
|
||||
declare class GeneratorState extends GeneratorState_base {
|
||||
getI18n(): I18n;
|
||||
getResources(): Resources;
|
||||
}
|
||||
export default GeneratorState;
|
||||
//# sourceMappingURL=state.d.ts.map
|
1
book/node_modules/honkit/lib/output/website/state.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/output/website/state.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/output/website/state.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,KAAK,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;;AAEzC,cAAM,cAAe,SAAQ,mBAI3B;IACE,OAAO,IAAI,IAAI;IAIf,YAAY,IAAI,SAAS;CAG5B;AAED,eAAe,cAAc,CAAC"}
|
20
book/node_modules/honkit/lib/output/website/state.js
generated
vendored
Normal file
20
book/node_modules/honkit/lib/output/website/state.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const i18n_t_1 = __importDefault(require("i18n-t"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
class GeneratorState extends immutable_1.default.Record({
|
||||
i18n: (0, i18n_t_1.default)(),
|
||||
// List of plugins' resources
|
||||
resources: immutable_1.default.Map()
|
||||
}) {
|
||||
getI18n() {
|
||||
return this.get("i18n");
|
||||
}
|
||||
getResources() {
|
||||
return this.get("resources");
|
||||
}
|
||||
}
|
||||
exports.default = GeneratorState;
|
Reference in New Issue
Block a user