mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-09 19:44:56 +02:00
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getFormat = void 0;
|
|
const tslib_1 = require("tslib");
|
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
// Copied from https://mdxjs.com/packages/mdx/#optionsmdextensions
|
|
// Although we are likely to only use .md / .mdx anyway...
|
|
const mdFormatExtensions = [
|
|
'.md',
|
|
'.markdown',
|
|
'.mdown',
|
|
'.mkdn',
|
|
'.mkd',
|
|
'.mdwn',
|
|
'.mkdown',
|
|
'.ron',
|
|
];
|
|
function getExtensionFormat(filepath) {
|
|
const isMDFormat = mdFormatExtensions.includes(path_1.default.extname(filepath));
|
|
// Bias toward mdx if unknown extension
|
|
return isMDFormat ? 'md' : 'mdx';
|
|
}
|
|
function getFormat({ filePath, frontMatterFormat, markdownConfigFormat, }) {
|
|
if (frontMatterFormat) {
|
|
if (frontMatterFormat !== 'detect') {
|
|
return frontMatterFormat;
|
|
}
|
|
return getExtensionFormat(filePath);
|
|
}
|
|
if (markdownConfigFormat !== 'detect') {
|
|
return markdownConfigFormat;
|
|
}
|
|
return getExtensionFormat(filePath);
|
|
}
|
|
exports.getFormat = getFormat;
|
|
//# sourceMappingURL=format.js.map
|