import * as plugins from './smartdocumentation.plugins.js'; export interface IDocumentationDirectoryConstructorOptions { pathArg: string; } /** * a documentation directory maps to a directory with markdown documents */ export class DocumentationDirectory { public options: IDocumentationDirectoryConstructorOptions; public smartmarkdownInstance = new plugins.smartmarkdown.SmartMarkdown(); public articles: plugins.tsclass.content.IArticle[]; constructor(optionsArg: IDocumentationDirectoryConstructorOptions) { this.options = optionsArg; } /** * reads a directory */ public async readDirectory() { const fileTreeComplete = await plugins.smartfile.fs.fileTreeToObject( this.options.pathArg, '**/*' ); const articles: plugins.tsclass.content.IArticle[] = []; for (const markdownFile of fileTreeComplete.filter( (fileArg) => fileArg.parsedPath.ext === '.md' )) { const parsedMarkdown = await this.smartmarkdownInstance.getMdParsedResultFromMarkdown(markdownFile.contents.toString()) articles.push({ title: parsedMarkdown.title, author: parsedMarkdown.frontmatterData.author, content: parsedMarkdown.originalString, timestamp: Date.now(), tags: [ `path:${markdownFile.path}`, ], }); } this.articles = articles; } sendAsDocumentationSet(nameArg: string, targetArg: string) { } }