Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexzhangs/jekyll-hooks
A Jekyll plugin to do find-and-replace in site content through hooks.
https://github.com/alexzhangs/jekyll-hooks
github-pages jekyll jekyll-hooks jekyll-plugins plugins
Last synced: 2 days ago
JSON representation
A Jekyll plugin to do find-and-replace in site content through hooks.
- Host: GitHub
- URL: https://github.com/alexzhangs/jekyll-hooks
- Owner: alexzhangs
- License: mit
- Created: 2021-10-25T13:03:46.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-28T11:54:03.000Z (about 3 years ago)
- Last Synced: 2024-12-27T17:13:20.239Z (14 days ago)
- Topics: github-pages, jekyll, jekyll-hooks, jekyll-plugins, plugins
- Language: Ruby
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jekyll-hooks
A Jekyll plugin to do find-and-replace in site content through hooks.The most requirements like this are implemented by putting a simple hooks plugin into `_plugins` folder.
But it's not gonna work with Github Pages, even at local.
Github Pages locks down the `safe=true`, the `_plugins` folder won't work at all.With this plugin, for the local build, it works.
For he remote build on Github Pages, of course it won't work by default.
But with [jekyll-deploy-action](https://github.com/jeffreytse/jekyll-deploy-action) together, it will.## Sample Configuration
```yaml
# _config.yml# jekyll-hooks
hooks:
actions:
- type: posts
exts: [markdown,mkdown,mkdn,mkd,md]
# ![alt](/path/to/image "title"){:.class}
find: >
!\[([^\]]*)\]\(((?!http[s]?://)[^"'\n]+)(?:\s['"]([^'"]*)['"])?\)(?:\{:\.([^{]+)\})?
# both present and non-present quotes matter
replace: >
{% picture \2 --alt \1 --img class="\4" title="\3" %}
case-insensitive: true
disabled: false
disabled: false
```This configuration is turning the following markdown code:
```markdown
![A happy dog](/assets/images/a-happy-dog.png "Leica iiif, Summaron 35mm/F3.5"){:.photo}
```into a [jekyll_picture_tag](https://github.com/rbuchberger/jekyll_picture_tag)
tag format which is used to generate responsive images HTML code:```
{% picture /assets/images/a-happy-dog.png --alt A happy dog --img class="photo" title="Leica iiif, Summaron 35mm/F3.5" %}
```