0

我当前的规则文件如下所示:

#!/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

我想用markdown而不是html来编写未来的文件。但是,似乎规则文件没有正确的规则来处理它。用 Markdown 编写的所有内容看起来都像是文本转储。

我错过了什么?

4

1 回答 1

3

看起来您compile对同一模式有两条规则 ( '*')。只有第一个会被执行,另一个会被默默地忽略。

您应该重新组织您的规则,以便compile与特定项目匹配的第一个规则是您要为其执行的规则。

例如,在我自己的Rules文件中,我有这样的安排:

编译 '/**/*.md' 做
  过滤器:kramdown
结尾

编译 '/**/*' 做
  写 item.identifier.to_s
结尾

换句话说,从一开始的更具体的规则到最后的更一般的规则。

于 2018-02-19T16:40:13.123 回答