UNPKG

ts-markdown

Version:

An extensible TypeScript markdown generator that takes JSON and creates a markdown document.

29 lines (28 loc) 805 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.frontmatter = exports.frontmatterRenderer = void 0; const yaml_1 = require("yaml"); /** * Renderer for frontmatter entries * * @param entry the frontmatter object entry * @param options * @returns */ const frontmatterRenderer = (entry) => { if ('frontmatter' in entry) { const frontmatterText = (0, yaml_1.stringify)(entry.frontmatter); return { markdown: `---\n${frontmatterText}---`, blockLevel: true, }; } throw new Error('Entry is not a frontmatter object. Unable to render'); }; exports.frontmatterRenderer = frontmatterRenderer; function frontmatter(content) { return { frontmatter: content, }; } exports.frontmatter = frontmatter;