Get Jekyll Configuration Inside Plugin

后端 未结 3 841
陌清茗
陌清茗 2021-02-07 03:58

I\'d like to make changes to the Jekyll Only First Paragraph plugin to make the generation of a \'read more \' link a configurable option.

To do this I\'d need to be abl

3条回答
  •  天涯浪人
    2021-02-07 04:52

    If you are working with Generators (which are also plugins), it is possible to get the configuration like this:

    class MyPlugin < Jekyll::Generator
      def generate(site)
        puts site.config["max_posts"] # max_posts as defined in _config.yml
    

    You'll get the site as an argument, and the .config is accessible as an hash.

提交回复
热议问题