1

So, trying out nanoc.

Have uploaded the output folder to gh-pages on github.

Having trouble with css to display its styles.

Tried adding filter :relativize_paths, :type => :css in Rules.

Compiled it again.

It's still not displaying properly.

What am I doing wrong?

You can see that the page doesn't display properly: http://arubyist.github.io/nanoc/

This is the Rules page:

compile '*' do
   if item[:extension] == 'css'
   # don’t filter stylesheets
 elsif item.binary?
 # don’t filter binary items
 else
   filter :erb
   layout 'default'
 end
end

 route '*' do
 if item[:extension] == 'css'
 # Write item with identifier /foo/ to /foo.css
 item.identifier.chop + '.css'
 elsif item.binary?
 # Write item with identifier /foo/ to /foo.ext
 item.identifier.chop + '.' + item[:extension]
else
# Write item with identifier /foo/ to /foo/index.html
item.identifier + 'index.html'
 end
 end

 layout '*', :erb

 compile '/html' do 
   filter :relativize_paths, :type => :html
  end 

 compile '/css' do
   filter :relativize_paths, :type => :css 
  end 
user273072545345
  • 1,536
  • 2
  • 27
  • 57

2 Answers2

0

To make it work, the filter must be at the end of the compile rule. For html you must place it after the layout statement. Example:

compile '*' do
  if item[:extension] == 'css'
    filter :relativize_paths, :type => :css 
  elsif item.binary?
    # don’t filter binary items
  else
    filter :kramdown
    filter :erb
    layout 'default'
    filter :relativize_paths, :type => :html
  end
end
Emiliano Poggi
  • 24,390
  • 8
  • 55
  • 67
-1

Your compile '*' rule at the top is winning and compiling all your files. It never even reaches the compile '/css' rule.

This should do:

compile '*' do
  if item[:extension] == 'css'
    filter :relativize_paths, :type => :css 
  elsif item.binary?
    # don’t filter binary items
  else
    filter :erb
    filter :relativize_paths, :type => :html
    layout 'default'
  end
end

route '*' do
  if item[:extension] == 'css'
    # Write item with identifier /foo/ to /foo.css
    item.identifier.chop + '.css'
  elsif item.binary?
    # Write item with identifier /foo/ to /foo.ext
    item.identifier.chop + '.' + item[:extension]
  else
    # Write item with identifier /foo/ to /foo/index.html
    item.identifier + 'index.html'
  end
end

layout '*', :erb
bobthecow
  • 5,047
  • 25
  • 27