From 49ad983da07d5ad0d20c0245f78b8ab7a4ee3212 Mon Sep 17 00:00:00 2001 From: sigmasternchen Date: Tue, 7 Jan 2025 20:38:14 +0100 Subject: [PATCH] docs: Update README to include information about the plugin system --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a564fb8..d6e8c44 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ for programming knowledge — simply modify YAML files to generate your site. - **Markdown Support**: Write content in Markdown, which is automatically converted to HTML. - **Tagging System**: Organize your content with tags for easy referencing in templates. - **File Inclusion**: Include other YAML files to create a modular content structure. +- **Plugin System**: Extend the functionality with modules that can be added at runtime. ## Getting Started @@ -26,7 +27,7 @@ To generate your static site, run the Grimoire command with your input YAML file You can specify an output directory using the `-o` or `--output` flag. ```bash -python -m grimoire-ssg -o output_directory one_or_more_input_files.yml +python -m grimoiressg -o output_directory one_or_more_input_files.yml ``` ### Alternative Installation @@ -43,7 +44,7 @@ poetry install You can then run the program directly using Poetry: ```bash -poetry run python -m grimoire-ssg -o output_directory one_or_more_input_files.yml +poetry run python -m grimoiressg -o output_directory one_or_more_input_files.yml ``` ### Example YAML File @@ -101,7 +102,11 @@ extends a layout and includes dynamic content:

My latest blog articles:

{% endblock %} @@ -126,7 +131,42 @@ Additionally, the following fields are defined: ### Output Structure -The output files will be generated in the specified output directory, with paths defined in the `output` attribute of your YAML files. +The output files will be generated in the specified output directory, with paths defined in the `output` +attribute of your YAML files. + +## Advanced Features + +### Custom Plugins + +The program supports the addition of custom plugins at runtime. To utilize this, create a Python module +that modifies the list of available modules: + +```Python +from grimoiressg.modules import available_modules + + +def test(data, context): + print("This is test module.") + + +available_modules["test"] = test + +``` + +You then need a config file that loads, and enables this module. Please note that you need to specify +all `enabled_modules` to be used - not just the additional one. + +```yaml +load_modules: + - external_module_test + +enabled_modules: + - tags # built-in module for tagging + - markdown # built-in module for markdown support + - templating # built-in module for templating + - test # our custom module; the name is the + # key in the `available_modules` dict above +``` ## Contributing