Injector: A Plugin for Pelican
Injector is a plugin for the Pelican static site generator that allows users to inject custom code before or after specific HTML tags, without modifying your theme.
Installation
This plugin can be installed via:
python -m pip install pelican-injector
As long as you have not explicitly added a PLUGINS setting to your Pelican settings file, then the newly-installed plugin should be automatically detected and enabled. Otherwise, you must add injector to your existing PLUGINS list. For more information, please see the How to Use Plugins documentation.
Settings
To configure the plugin, set the INJECTOR_ITEMS variable in your
Pelican settings file. This should be a list of tuples, each with two
or three elements, according to this table:
| Tuple Element | Description |
|---|---|
| First | Name of the HTML tag where you want to inject your code |
| Second | The code you want to inject |
| Third (optional) | Specifies where to inject the code: 'before' or 'after'. If not provided, it defaults to 'after' |
INJECTOR_ITEMS = [
('head', '<script>...</script>', 'after'),
('body', '<div>...</div>', 'before'),
// add more tags and code as needed
]
In the following example, a script logging "Hello, world!" to the console is
injected into the <head> tag of each page, and a style block is injected
before the <body> tag.
INJECTOR_ITEMS = [
('head', '<script>console.log("Hello, world!");</script>'),
('body', '<style>.custom-style { color: red; }</style>', 'before'),
]
INJECTOR_IN_PAGES = True
INJECTOR_IN_ARTICLES = False
Contributing
Contributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on existing issues.
To start contributing to this plugin, review the Contributing to Pelican documentation, beginning with the Contributing Code section.
License
This project is licensed under the MIT license.
Contact
If you have any questions or feedback, please open an issue on GitHub.
Release files for pelican-injector 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pelican_injector-1.0.0.tar.gz | 6.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pelican_injector-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / pelican_injector-1.0.0.tar.gz
| Download URL | pelican_injector-1.0.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9aeefd346af03b0637ae2c38252786f8a8ec309bb0d7dd3727428d1ddda35f50
|
|
BLAKE2b-256 checksum How to use checksums |
a373f59b13f44149d95aba2fe5653060168f03ea9f252fb403c289c5a35f31fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / pelican_injector-1.0.0-py3-none-any.whl
| Download URL | pelican_injector-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc41860ce7d80f1743df1263910241848d662bfc7c267adce3cc7fa8d346dace
|
|
BLAKE2b-256 checksum How to use checksums |
60d71110ef886af7e8dbded4ce7ff5b30b2869f32dd7c1eedc6c7a51af55a1eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|