How can I get Nanoc to compile the same item in more than one way?

StackOverflow https://stackoverflow.com/questions/13431027

  •  30-11-2021
  •  | 
  •  

سؤال

I want to have Nanoc compile a single item in multiple formats - specifically, compile a Markdown file to both HTML and PDF. As far as I know, a single item can only match a single compilation rule.

A hard link (ln somefile.md newfile.md) allows me to compile the same file as if it were two different files, but that's kind of an awkward solution.

Is there a better way to do this?

هل كانت مفيدة؟

المحلول

You can use item representations in order to achieve that. You can compile a single item into multiple output items (representations). Here’s an example:

compile '/stuff/' do
  filter :markdown
end

compile '/stuff/', :rep => :pdf do
  filter :markdown
  filter :pdf
end

The only thing remaining is to provide routing rules that write the two item representations to their right location (also using :rep => ...).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top