0

My current rules file looks as follows:

#!/usr/bin/env ruby

### COMPILATION RULES

# Don’t filter or layout assets
compile %r{^/(favicon|robots|crypto/.*|stylesheets/.*|javascript/.*|plugins/.*|fonts/.*|images/.*|photos/.*|keybase.txt)/$} do
end

# compile '/' do
#   filter :erb
#   layout 'default'
# end

compile '*' do
  if item.binary?
    # don’t filter binary items
  else
    layout item[:layout] || 'default'
  end
end



# Sitemap, RSS feed, and htaccess get filtered with erb, but get no layout.
compile %r{^/(sitemap|htaccess|feed|card|identity)/$} do
  filter :erb
end

# Songs get rendered in the music player
compile %r{^/music/.*/$} do
  filter :erb
  layout 'player'
end


compile '*' do
  case item[:extension]
    when 'md'
      filter :kramdown
    when 'html'
      filter :erb
  end
  layout 'default'
end

route '/photos/*/', :rep => :thumbnail do
  item.identifier.chop + '-thumbnail.' + item[:extension]
end

route %r{^/(favicon|robots|sitemap|crypto/.*|stylesheets/.*|javascript/.*|plugins/.*|fonts/.*|images/.*|photos/.*)/$} do
  ext = item[:extension]
  item.identifier.chop + '.' + ext
end

route '*' do
  item.identifier + 'index.html'
end

layout '*', :erb

I want to write future files in markdown instead of html. However, seems like the rule file does not have the right rule to process it. Everything written in markdown looks like a text dump.

What am I missing?

kingmakerking
  • 2,017
  • 2
  • 28
  • 44

1 Answers1

3

It looks like you have two compile rules for the same pattern ('*'). Only the first of those will be executed, and the other one will be silently ignored.

You should reorganize your rules so that the first compile rule that matches a particular item is the one you want to have executed for it.

In my own Rules file, for example, I have this kind of arrangement:

compile '/**/*.md' do
  filter :kramdown
end

compile '/**/*' do
  write item.identifier.to_s
end

In other words, working from more specific rules at the beginning to more general rules towards the end.

Ian Young
  • 121
  • 5
  • 2
    It’s true that Nanoc silently ignores unused rules. While not problematic, it can be misleading; I’ve created a GitHub issue for this (https://github.com/nanoc/features/issues/37) to make situations like these easier to detect and solve. – Denis Defreyne Feb 19 '18 at 17:29