UNPKG

md-curcuma

Version:

A Typescript library for transporting and converting markdown and other data.

46 lines (45 loc) 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MD_Frontmatter_Task = void 0; const MD_FileContent_1 = require("./helpers/MD_FileContent"); const MD_Observable_Abstract_TaskBase_1 = require("./MD_Observable_Abstract_TaskBase"); const mapper_1 = require("../../core/mapper"); class MD_Frontmatter_Task extends MD_Observable_Abstract_TaskBase_1.MD_Observable_Abstract_TaskBase { constructor(parameter) { super(); this.collection = null; this.counter = 0; this.doCollect = false; this.template_values = { content: "", }; this.parameter = parameter; } perform(dao) { dao = super.perform(dao); return dao; } transform(mdfc, index) { if (index === 0) { mdfc.frontmatter; mdfc.frontmatter_attributes; const template_content = MD_FileContent_1.MD_FileContent.split_frontmatter_body(this.parameter.frontmatter.get_template_string()); template_content.frontmatter; template_content.frontmatter_attributes; console.log("Frontmatter-Source:", mdfc.frontmatter_attributes, ", Frontmatter-Target:", template_content.frontmatter_attributes); var fm_old = mdfc.frontmatter_attributes; var fm_new = template_content.frontmatter_attributes; for (let prop in fm_old) { if (fm_new.hasOwnProperty(prop)) { fm_new[prop] = fm_old[prop]; } } const mapper = new mapper_1.Mapper(); mapper.addMappings(this.parameter.mappings); mapper.do_mappings(mdfc.frontmatter_attributes, fm_new); mdfc.frontmatter_attributes = Object.assign({}, fm_new); } return mdfc; } } exports.MD_Frontmatter_Task = MD_Frontmatter_Task;