UNPKG

@mdfriday/foundry

Version:

The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.

70 lines 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Content = void 0; exports.newContent = newContent; class Content { constructor(source) { /** Final rendered HTML content */ this.renderedContent = ''; /** Content summary */ this.summary = ''; /** Word count */ this.wordCount = 0; /** Reading time in minutes */ this.readingTime = 0; this.lazyRendered = true; this.rawSource = source; } /** * Update content with parsed and rendered data */ updateWithContentResult(result) { if (result.frontMatter) { this.frontMatter = result.frontMatter; } this.renderedContent = result.renderedContent || ''; this.summary = result.summary; this.wordCount = result.wordCount || 0; this.readingTime = result.readingTime || 0; } /** * Get raw source content */ getRawSource() { return this.rawSource; } async RenderedContent() { await this.render(); return this.renderedContent; } async Summary() { await this.render(); return this.summary; } async WordCount() { await this.render(); return this.wordCount; } async ReadingTime() { await this.render(); return this.readingTime; } async render() { if (this.lazyRendered && this.lazyRender) { await this.lazyRender(); this.lazyRendered = false; } return Promise.resolve(); } /** * Check if content is empty */ isEmpty() { return !this.rawSource || this.rawSource.length === 0; } } exports.Content = Content; function newContent(source) { return new Content(source); } //# sourceMappingURL=pagecontent.js.map