【问题标题】:How do I include font-awesome-sass gem in Jekyll project如何在 Jekyll 项目中包含 font-awesome-sass gem
【发布时间】:2014-06-15 00:21:38
【问题描述】:

所以我有一个 Jekyll 项目,我从这里安装了 font-awesome-sass gem:https://github.com/FortAwesome/font-awesome-sass

它只有在 Rails 项目中使用它的说明,但是如何在 Rails 之外使用 gem?

我在我的 _plugins 文件夹中放了一个简单的文件,它只有一行:

require 'font-awesome-sass'

从自述文件中,我了解到 gem 会生成一个 scss 文件,我需要告诉它在哪里放置 font-awesome.scss 文件。我该怎么做呢?任何方向或资源将不胜感激。

【问题讨论】:

    标签: ruby gem jekyll


    【解决方案1】:

    请注意,最新的 Jekyll 已经可以“开箱即用”处理 sass、scss 和 coffee 文件,请参阅 this link,因此您可能不需要使用特定的 gem。

    但如果你真的想使用那个特定的 gem,你可以做我在发现 Sass 转换已经内置之前使用的方法。我在_plugins 中提取了这个简单的sass-converter.rb 文件,该文件是从GitHub 页面获得的(但我不记得是哪个了,抱歉)。它需要普通的 sass gem,但我认为您可以对特定的 gem 做类似的事情:

    module Jekyll
      # Sass plugin to convert .scss to .css
      #
      # Note: This is configured to use the new css like syntax available in sass.
    
      require 'sass'
    
      class SassConverter < Converter
        safe true
        priority :low
    
        def matches(ext)
          ext =~ /scss/i
        end
    
        def output_ext(ext)
          ".css"
        end
    
        def convert(content)
          begin
            puts "\nPerforming Sass Conversion."
            # put your own call and options here:
            engine = Sass::Engine.new(content, :syntax => :scss, :load_paths => ["./"], :style => :expanded)
            engine.render
          rescue StandardError => e
            puts "\n!!! SASS Error: " + e.message
          end
        end
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-31
      • 1970-01-01
      • 2014-09-24
      • 1970-01-01
      相关资源
      最近更新 更多