UNPKG

conflutora

Version:

Provider to convert and publish Antora documentation on Confluence

80 lines 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Page = void 0; const change_case_1 = require("change-case"); const types_1 = require("../types"); const hash_util_1 = require("../utils/hash.util"); const enum_1 = require("../common/enum"); /** * Represents a page within the site structure for publishing to Confluence. */ class Page { id; // Unique hash ID of the page fileName; // Name of the file - index.html by default title; // Title of the page extracted from content parent; // Title of the parent page or directory name fqfn; // Fully qualified file name content; // HTML content of the page // Confluence properties confluenceStatus; // Current status of the page in the publication process confluenceVersion; // Version of the page in Confluence confluenceId; // ID of the page in Confluence confluenceParentId; // ID of the parent page in Confluence constructor(fileName, title, parent, content) { const fqfn = `${parent}/${fileName}`; this.id = (0, hash_util_1.calculateHash)(fqfn); this.fileName = fileName ?? enum_1.ANTORA_DEFAULTS.INDEX_PAGE; this.title = title; this.parent = parent; this.fqfn = fqfn; this.content = content; this.confluenceStatus = types_1.ConfluencePageStatus.CURRENT; this.confluenceVersion = 0; } getParent() { return this.parent.split('/').pop() ?? this.parent; } getName() { if (this.isIndex()) { return (0, change_case_1.capitalCase)(this.getParent()).replace(/^(\d+)(\s)/, '$1.$2').trim(); } else { return this.title.trim(); } } isIndex() { return this.fileName === enum_1.ANTORA_DEFAULTS.INDEX_PAGE; } isRoot() { return !this.parent.includes('/'); } toJSON() { return { id: this.id, fileName: this.fileName, title: this.title, parent: this.parent, fqfn: this.fqfn, confluenceStatus: this.confluenceStatus, confluenceVersion: this.confluenceVersion, confluenceId: this.confluenceId, confluenceParentId: this.confluenceParentId }; } setConfluenceId(id) { this.confluenceId = id; } setConfluenceParentId(id) { this.confluenceParentId = id; } setVersion(version) { if (!version) return; this.confluenceVersion = version; } getHash() { return (0, hash_util_1.calculateHash)(this.content); } } exports.Page = Page; //# sourceMappingURL=Page.js.map