@mintlify/prebuild
Version:
Helpful functions for Mintlify's prebuild step
34 lines (33 loc) • 1.18 kB
JavaScript
import { coreRemark, getAST, preprocessCustomHeadingIds } from '@mintlify/common';
import { formatError } from '../../errorMessages/formatError.js';
export { formatError };
export const preparseMdx = async (fileContent, contentDirectoryPath, filePath, onError) => {
try {
return String(await coreRemark().process(preprocessCustomHeadingIds(fileContent)));
}
catch (error) {
const message = formatError(error, filePath, contentDirectoryPath);
if (onError) {
onError(message);
}
else {
console.log(message);
}
return `🚧 A parsing error occurred. Please contact the owner of this website.`;
}
};
export const preparseMdxTree = async (fileContent, contentDirectoryPath, filePath, onError) => {
try {
return getAST(fileContent, filePath);
}
catch (error) {
const message = formatError(error, filePath, contentDirectoryPath);
if (onError) {
onError(message);
}
else {
console.error(message);
}
return getAST(`🚧 A parsing error occurred. Please contact the owner of this website.`);
}
};