they works internally ◦ Most of their features are unneeded though • Difficult to customize and personalize ◦ Custom styling? ◦ Custom directory structure? ◦ Custom Markdown parsing? ◦ Software Trade-off: Customizability v.s. Integrity • Good for common purposes (documentation, book, etc), but may not fit well for personal usages.
date and tags for posts) class Pipe { nextPipes = []; // A virtual function to be overridden. operate(input) { ... } pipe(nextPipe) { if (!this.nextPipes.includes(nextPipe)) this.nextPipes.push(nextPipe); return nextPipe; } async execute(input) { const output = await this.operate(input); if (output) this.nextPipes.map(next => next.execute(output)); } } Pipe FileData FileData
single output. • Example: Pug template compiler Compilation (cont.) class PugCompiler extends Pipe { ... // Uses 2 inputs; one is a template file and // the other is a date file. Each data file // will produce an output. async operate(input) { if (input instanceof FileData && input.extname == '.pug') { this.resolveTemplate( pug.compile(input.content)); } else { const template = await this.promisedTemplate; input.content = template(input); return input; } } } Target FileData Source FileData Compiler
inputs = []; // The count of inputs to be aggregated per // output. aggregationCount; // Determines the order of the aggregated // inputs. compareFunction; operate(input) { this.inputs.push(input); if (this.inputs.length == this.aggregationCount) { this.inputs.sort(this.compareFunction); this.file.metadata.inputs = this.inputs; this.inputs = []; return this.file; } } } Serial FileData Aggregator A single FileData • Aggregate multiple inputs into a single input. • Example: Post list page
to FileReader) • Pagination ◦ Pager pipe (similar to Aggregator) • Testability ◦ StringWriter pipe (instead of FileWriter) ◦ ... but who cares of tests for a personal blog? • Cache ◦ Per-pipe cache using hash • Have fun!