import{HtmlPage}from"../../html";importFilefrom"./file";importtype{PageSettings}from"../../types/site";/** * Represents any file that can be read as a UTF-8 string. */classTextFileextendsFile{// The string contents of the fileprotectedasString?: string;read(){this.asString=this.path.readString();returnthis;}/** * Write a file to a path at the provided config location. */write(config: PageSettings=this.cachedConfig){const{ sourceDir, targetDir }=config;consttargetPath=this.path.relativeTo(sourceDir,targetDir);targetPath.writeString(this.serve(config).contents);returnthis;}text(config?: PageSettings): string{if(!this.asString){this.read();}returnthis.asStringasstring;}toString(){returnthis.text(this.cachedConfig);}asHtml(settings: PageSettings){returnHtmlPage.create(["Article",{file: this, ...settings},["SourceBlock",{file: this}]],settings);}serve(settings: PageSettings){return{contents: this.text(settings),mimeType: this.mimeType};}}exportdefaultTextFile;