@paroicms/server
Version:
The ParoiCMS server
25 lines • 1.16 kB
JavaScript
import { getNodeTypeByName } from "@paroicms/internal-anywhere-lib";
import { createBackendPluginService } from "../plugin-services/make-backend-plugin-service.js";
export async function applyMarkdownToNativeForValues(siteContext, values, typeName, language) {
const nodeType = getNodeTypeByName(siteContext.siteSchema, typeName);
const fieldTypes = nodeType.fields ?? [];
const result = { ...values };
const list = siteContext.hooks.get("markdownToNative");
if (!list || list.length === 0)
return result;
const { handler, plugin } = list[0];
const service = createBackendPluginService(siteContext, plugin);
for (const fieldType of fieldTypes) {
const value = values[fieldType.name];
if (value === undefined || value === null)
continue;
if (typeof value !== "string")
continue;
if (fieldType.dataType !== "json" || fieldType.renderAs !== "html")
continue;
const converted = await handler({ service, value, options: { language } });
result[fieldType.name] = converted;
}
return result;
}
//# sourceMappingURL=markdown-content.js.map