mirror of
https://github.com/PR0M3TH3AN/Archivox.git
synced 2025-09-08 06:58:43 +00:00
Add plugin system
This commit is contained in:
40
README.md
40
README.md
@@ -126,6 +126,7 @@ features:
|
||||
provider: "plausible"
|
||||
id: "my-site.io"
|
||||
|
||||
pluginsDir: "plugins" # Folder for custom plugins
|
||||
plugins:
|
||||
- "analytics" # Load from plugins/
|
||||
```
|
||||
@@ -223,4 +224,43 @@ To make DocForge truly user-friendly, include these instructions in the starter
|
||||
- **Future**: PDF export plugin, AI-assisted search suggestions.
|
||||
- **Community**: MIT license; GitHub for issues.
|
||||
|
||||
## Creating Custom Plugins
|
||||
|
||||
Plugins are plain Node.js modules placed in the folder defined by `pluginsDir`.
|
||||
Each module can export hook functions which DocForge calls during the build:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
// Modify markdown before frontmatter is parsed
|
||||
async onParseMarkdown({ file, content }) {
|
||||
return { content };
|
||||
},
|
||||
// Modify the final HTML of each page
|
||||
async onPageRendered({ file, html }) {
|
||||
return { html };
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Example `plugins/analytics.js`:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
onPageRendered: async ({ html, file }) => {
|
||||
const snippet = `\n<script>console.log('Page viewed: ${file}')</script>`;
|
||||
return { html: html.replace('</body>', `${snippet}</body>`) };
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Enable it in `config.yaml`:
|
||||
|
||||
```yaml
|
||||
pluginsDir: "plugins"
|
||||
plugins:
|
||||
- "analytics"
|
||||
```
|
||||
|
||||
Running `npm run build` will load the plugin and execute its hooks.
|
||||
|
||||
This spec is complete and ready for implementation. Prototype core parsing first, then add features iteratively. Total est. dev time: 2-4 weeks for MVP.
|
||||
|
Reference in New Issue
Block a user