Skip to content

Instantly share code, notes, and snippets.

@mgrandrath
Forked from parkr/generator_scss.rb
Last active November 17, 2020 05:46
Show Gist options
  • Save mgrandrath/8282339 to your computer and use it in GitHub Desktop.
Save mgrandrath/8282339 to your computer and use it in GitHub Desktop.
#
# Jekyll Generator for SCSS
#
# (File paths in this description relative to jekyll project root directory)
# Place this file in ./_plugins
# Place .scss files in ./_scss
# Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
# Config file placed in ./_sass/config.rb
require 'compass'
require 'compass/exec'
module Jekyll
class CompassGenerator < Generator
safe true
def initialize(site_config)
super
@site_config = site_config
end
def generate(site)
Dir.chdir sass_dir do
Compass::Exec::SubCommandUI.new(%w(compile)).run!
end
site.read_directories(css_path(Compass.configuration))
end
private
def sass_path
'_sass'
end
def sass_dir
File.expand_path(sass_path, base_dir)
end
def css_path(compass_config)
normalize(File.join(sass_path, compass_config.css_dir))
end
def base_dir
@site_config[:source]
end
def normalize(path)
Pathname.new(path).cleanpath.to_s
end
end
end
@detly
Copy link

detly commented Mar 3, 2016

I just get:

jekyll 3.1.2 | Error:  undefined method `read_directories' for #<Jekyll::Site:0x000000023bef00>

@obilodeau
Copy link

@detly I know I'm probably too late but in case anyone stumbles upon this. The fix is to change: site.read_directories to site.reader.read_directories.

@detly
Copy link

detly commented Nov 17, 2020

@detly I know I'm probably too late but

No, once every four years is about how frequently I update my blog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment