Route and Compile

16 views
Skip to first unread message

Pito Salas

unread,
Jul 1, 2020, 9:08:44 PM7/1/20
to na...@googlegroups.com
I’m having a little trouble with this scenario:

compile '/**/*.md.erb', rep: :slides do
if item[:status] != "hidden"
filter :erb
layout '/slides.*'
write item.identifier.without_ext + '/slides.html'
else
nil
end
end

compile '/**/*.{md,ical}.erb' do
if item[:status] != "hidden"
filter :erb
filter :kramdown, coderay_line_numbers: nil
layout '/course.*'
else
nil
end
end


# Select which .md.erb becomes the home page of the site
route "/content/welcome/10_syllabus.md.erb" do
'/index.html'
end

route "/content/welcome/10_syllabus.md.erb", rep: :slides do
'/slides.html’
end

My intention is that "/content/welcome/10_syllabus.md.erb” is compiled both with the course layout and the slides layout, and then that the result is that a file called index.html and one called slides.html are generated at output/…

The first one (compile with layout slides) works great, but the second one doesn’t do anything.

If it helps, here’s the repo: https://github.com/pitosalas/cosi102r

Thanks!



Pito Salas
Brandeis Computer Science
Volen 134

Denis Defreyne

unread,
Jul 11, 2020, 4:57:30 AM7/11/20
to na...@googlegroups.com
Hey Pito,

I believe the issue is this: If a compilation rule uses #write, Nanoc doesn’t look for a routing rule. I find that mixing #write and routing rules is often confusing, and I recommend sticking to one approach (I prefer #write).

Here’s what it could look like with #write (note that you don’t need the else nil):

compile '/**/*.md.erb', rep: :slides do
  if item[:status] != "hidden"
    filter :erb
    layout '/slides.*'
    write '/slides.html'

  end
end

compile '/**/*.{md,ical}.erb' do
  if item[:status] != "hidden"
    filter :erb
    filter :kramdown, coderay_line_numbers: nil
    layout '/course.*'
    write '/index.html'
  end
end

You can then remove the matching routing rules, as they won’t be used anymore.

I also noticed that the second compilation rule matches *.ical.erb files, while the first one does not. That might be an issue as well.

Does that help?

Best,

Denis


--
You received this message because you are subscribed to the Google Groups "nanoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanoc+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nanoc/27BB41DF-E54F-4CAC-89A7-0C9AE4D16CB5%40brandeis.edu.


--
Reply all
Reply to author
Forward
0 new messages