This commit is contained in:
2025-05-12 05:38:44 +09:00
parent dced21c3f8
commit 6d78bfa46e
8120 changed files with 1161564 additions and 0 deletions

View File

@ -0,0 +1,10 @@
/**
* Convert a filePath (absolute) to a filename for output
*
* @param {Output} output
* @param {string} filePath
* @return {string}
*/
declare function fileToOutput(output: any, filePath: any): string;
export default fileToOutput;
//# sourceMappingURL=fileToOutput.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"fileToOutput.d.ts","sourceRoot":"","sources":["../../../src/output/helper/fileToOutput.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AAEH,iBAAS,YAAY,CAAC,MAAM,KAAA,EAAE,QAAQ,KAAA,UAerC;AAED,eAAe,YAAY,CAAC"}

View File

@ -0,0 +1,30 @@
"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 path_2 = __importDefault(require("../../utils/path"));
const location_1 = __importDefault(require("../../utils/location"));
const OUTPUT_EXTENSION = ".html";
/**
* Convert a filePath (absolute) to a filename for output
*
* @param {Output} output
* @param {string} filePath
* @return {string}
*/
function fileToOutput(output, filePath) {
const book = output.getBook();
const readme = book.getReadme();
const fileReadme = readme.getFile();
if (path_1.default.basename(filePath, path_1.default.extname(filePath)) == "README" ||
(fileReadme.exists() && filePath == fileReadme.getPath())) {
filePath = path_1.default.join(path_1.default.dirname(filePath), `index${OUTPUT_EXTENSION}`);
}
else {
filePath = path_2.default.setExtension(filePath, OUTPUT_EXTENSION);
}
return location_1.default.normalize(filePath);
}
exports.default = fileToOutput;

View File

@ -0,0 +1,15 @@
/**
Convert a filePath (absolute) to an url (without hostname).
It returns an absolute path.
"README.md" -> "/"
"test/hello.md" -> "test/hello.html"
"test/README.md" -> "test/"
@param {Output} output
@param {string} filePath
@return {string}
*/
declare function fileToURL(output: any, filePath: any): string;
export default fileToURL;
//# sourceMappingURL=fileToURL.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"fileToURL.d.ts","sourceRoot":"","sources":["../../../src/output/helper/fileToURL.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,iBAAS,SAAS,CAAC,MAAM,KAAA,EAAE,QAAQ,KAAA,UAWlC;AAED,eAAe,SAAS,CAAC"}

View File

@ -0,0 +1,30 @@
"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 location_1 = __importDefault(require("../../utils/location"));
const fileToOutput_1 = __importDefault(require("./fileToOutput"));
/**
Convert a filePath (absolute) to an url (without hostname).
It returns an absolute path.
"README.md" -> "/"
"test/hello.md" -> "test/hello.html"
"test/README.md" -> "test/"
@param {Output} output
@param {string} filePath
@return {string}
*/
function fileToURL(output, filePath) {
const options = output.getOptions();
const directoryIndex = options.get("directoryIndex");
filePath = (0, fileToOutput_1.default)(output, filePath);
if (directoryIndex && path_1.default.basename(filePath) == "index.html") {
filePath = `${path_1.default.dirname(filePath)}/`;
}
return location_1.default.normalize(filePath);
}
exports.default = fileToURL;

View File

@ -0,0 +1,3 @@
declare const _default: {};
export default _default;
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/output/helper/index.ts"],"names":[],"mappings":";AAAA,wBAAkB"}

3
book/node_modules/honkit/lib/output/helper/index.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {};

View File

@ -0,0 +1,10 @@
/**
* Resolve an absolute path (extracted from a link)
*
* @param {Output} output
* @param {string} filePath
* @return {string}
*/
declare function resolveFileToURL(output: any, filePath: any): string;
export default resolveFileToURL;
//# sourceMappingURL=resolveFileToURL.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"resolveFileToURL.d.ts","sourceRoot":"","sources":["../../../src/output/helper/resolveFileToURL.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,iBAAS,gBAAgB,CAAC,MAAM,KAAA,EAAE,QAAQ,KAAA,UAYzC;AAED,eAAe,gBAAgB,CAAC"}

View File

@ -0,0 +1,25 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const location_1 = __importDefault(require("../../utils/location"));
const fileToURL_1 = __importDefault(require("./fileToURL"));
/**
* Resolve an absolute path (extracted from a link)
*
* @param {Output} output
* @param {string} filePath
* @return {string}
*/
function resolveFileToURL(output, filePath) {
// Convert /test.png -> test.png
filePath = location_1.default.toAbsolute(filePath, "", "");
const page = output.getPage(filePath);
// if file is a page, return correct .html url
if (page) {
filePath = (0, fileToURL_1.default)(output, filePath);
}
return location_1.default.normalize(filePath);
}
exports.default = resolveFileToURL;

View File

@ -0,0 +1,11 @@
/**
Write a file to the output folder
@param {Output} output
@param {string} filePath
@param {Buffer|String} content
@return {Promise}
*/
declare function writeFile(output: any, filePath: any, content: any): any;
export default writeFile;
//# sourceMappingURL=writeFile.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"writeFile.d.ts","sourceRoot":"","sources":["../../../src/output/helper/writeFile.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,iBAAS,SAAS,CAAC,MAAM,KAAA,EAAE,QAAQ,KAAA,EAAE,OAAO,KAAA,OAU3C;AAED,eAAe,SAAS,CAAC"}

View File

@ -0,0 +1,26 @@
"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"));
/**
Write a file to the output folder
@param {Output} output
@param {string} filePath
@param {Buffer|String} content
@return {Promise}
*/
function writeFile(output, filePath, content) {
const rootFolder = output.getRoot();
filePath = path_1.default.join(rootFolder, filePath);
return fs_1.default
.ensureFile(filePath)
.then(() => {
return fs_1.default.writeFile(filePath, content);
})
.thenResolve(output);
}
exports.default = writeFile;