@mintlify/prebuild
Version:
Helpful functions for Mintlify's prebuild step
34 lines (33 loc) • 1.12 kB
JavaScript
import { coreRemark, getAST } 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(fileContent));
}
catch (error) {
const message = formatError(error, filePath, contentDirectoryPath);
if (onError) {
onError(message);
}
else {
console.log(message);
}
return `🚧 A parsing error occured. 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 occured. Please contact the owner of this website.`);
}
};