【问题标题】:Simple Jekyll converter plugin not working简单的 Jekyll 转换器插件不起作用
【发布时间】:2023-03-13 22:05:02
【问题描述】:

我正在尝试创建一个简单的 Jekyll 转换器插件,它几乎是 Converter Plugin in the Jekyll Documentation 的完整克隆,但它似乎不起作用:

module Jekyll
  class MyConverter < Converter
    safe false
    priority :high

    def matches(ext)
      ext =~ /^\.(md|markdown)$/i
    end

    def output_ext(ext)
      ".html"
    end

    def convert(content)
      content.upcase
    end
  end
end

我已将此文件 my_converter.rb 放入我的 _plugins 目录中。

现在,当我执行bundle exec jekyll serve 时,我希望看到呈现为 HTML 的每个降价页面的内容都转换为大写。然而,似乎什么也没有发生。

我错过了什么? (顺便说一句,我是 Ruby 新手。)

【问题讨论】:

标签: ruby plugins converter jekyll


【解决方案1】:

问题解决了。事实证明,上面的代码并没有什么问题。

问题在于,在某个时候,github-pages gem 已添加到我们的 Gemfile 中(不需要)。显然,使用 github-pages 插件,Jekyll is always started in safe mode and the plugin_dir is a random string

从我们的 Gemfile 中删除 github-pages gem 修复了它!

【讨论】:

    猜你喜欢
    • 2015-10-06
    • 1970-01-01
    • 2013-12-20
    • 2013-12-15
    • 2020-09-18
    • 2012-02-28
    • 2021-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多