-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblogEngine.ts
More file actions
41 lines (30 loc) · 901 Bytes
/
Copy pathblogEngine.ts
File metadata and controls
41 lines (30 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { PluginManager } from "./pluginManager";
import { SWContext, SWPlugin } from "./types";
// Structure of plugin
/*{
name: "plugin-name",
// context -> processing data content
execute: (context) => {
// Process the content which is inside the context and return the modified context
return context;
}
}*/
export class BlogEngine {
pluginManager: PluginManager;
constructor() {
this.pluginManager = new PluginManager();
}
use(plugin: SWPlugin) {
this.pluginManager.register(plugin);
return this;
}
process(content: string): SWContext {
console.log();
console.log("Content is processing...\n");
const context: SWContext = {
content
};
const finalResult = this.pluginManager.execute(context);
return finalResult;
}
};