I want to take and put some of the files under bower_components
folder. In my web site, bower_components
folder tree is as follows:
├── bower_components
│ └── angular
│ ├── README.md
│ ├── angular-csp.css
│ ├── angular.js
│ ├── angular.min.js
│ ├── angular.min.js.gzip
│ ├── angular.min.js.map
│ └── bower.json
I just want to copy the angular.min.js
file to the output/bower_components/angular/angular.min.js
folder.
For this purpose, I modified the Rules file as below:
compile "/bower_components/*.min.js" do
#item.identifier.chop + '.' + item[:extension]
end
route "/bower_components/*.min.js" do
item.identifier.chop + '.' + item[:extension]
end
When I compile my website, I have the following error:
RuntimeError: Found 4 content files for content/bower_components/angular/angular; expected 0 or 1
Compilation stack:
(empty)
Stack trace:
0. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/data_sources/filesystem.rb:164:in `block in all_split_files_in'
1. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/data_sources/filesystem.rb:154:in `each_pair'
2. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/data_sources/filesystem.rb:154:in `all_split_files_in'
3. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/data_sources/filesystem.rb:78:in `load_objects'
4. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/data_sources/filesystem.rb:37:in `items'
5. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/base/source_data/site.rb:325:in `block in load_items'
6. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/base/source_data/site.rb:324:in `each'
7. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/base/source_data/site.rb:324:in `load_items'
8. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/base/source_data/site.rb:243:in `load'
9. /Users/neva/.rvm/gems/ruby-1.9.3-p448@global/gems/nanoc-3.6.7/lib/nanoc/base/source_data/site.rb:127:in `layouts'
... 27 more lines omitted. See full crash log for details.
What shall be the problem?
Do you have any idea?
Because of the way it maps input filenames onto output paths, Nanoc requires the base name (i.e., the filename less extension) of each file under content
to be unique. From Nanoc's perspective you are giving it four files that share the base name angular
and thus cannot have unique output paths, so it gives you this error.
Since what you really want is to have Nanoc copy over this portion of your site verbatim, you ought to set up a static data source from which to load it. Then Nanoc will simply copy the files over as-is without attempting to process or rename them. The "Troubleshooting" page on the Nanoc website has instructions on how to do this; see "Solution #2" under "Error: “Found 3 content files for X; expected 0 or 1”.