UNPKG

@telefonica/markdown-confluence-sync

Version:

Creates/updates/deletes Confluence pages based on markdown files in a directory. Supports Mermaid diagrams and per-page configuration using frontmatter metadata. Works great with Docusaurus

28 lines (27 loc) 1.24 kB
// SPDX-FileCopyrightText: 2024 Telefónica Innovación Digital // SPDX-License-Identifier: Apache-2.0 import { getIndexFile } from "../util/files.js"; import { DocusaurusDocTreePage } from "./DocusaurusDocTreePage.js"; import { DocusaurusDocTreePageMdx } from "./DocusaurusDocTreePageMdx.js"; import globule from "globule"; import { relative } from "path"; import { IndexFileIgnoreException } from "../pages/errors/IndexFileIgnoreException.js"; export const DocusaurusDocTreePageFactory = class DocusaurusDocTreePageFactory { static fromPath(path, options) { return this._obtainedDocusaurusDocTreePage(path, options); } static fromCategoryIndex(path, options) { const indexPath = getIndexFile(path, options); if (options.filesIgnore && globule.isMatch(options.filesIgnore, relative(options.cwd, indexPath))) { throw new IndexFileIgnoreException(path); } return this._obtainedDocusaurusDocTreePage(indexPath, options); } static _obtainedDocusaurusDocTreePage(path, options) { if (path.endsWith(".mdx")) { return new DocusaurusDocTreePageMdx(path, options); } return new DocusaurusDocTreePage(path, options); } };