Skip to content

A Jekyll plugin to do find-and-replace in site content through hooks.

License

Notifications You must be signed in to change notification settings

alexzhangs/jekyll-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 together, it will.

Sample Configuration

# _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:

![A happy dog](/assets/images/a-happy-dog.png "Leica iiif, Summaron 35mm/F3.5"){:.photo}

into a 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" %}

About

A Jekyll plugin to do find-and-replace in site content through hooks.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages