algolia / frontman

💎 A Ruby-based static website generator
https://rubygems.org/gems/frontman-ssg
MIT License
109 stars 4 forks source link

undefined method `data' for #<Frontman::App:0x0000562ba8230c60> #28

Closed westonganger closed 4 years ago

westonganger commented 4 years ago

Using data within any view template results in the following error.

Just following the instructions on https://github.com/algolia/frontman/wiki/Data-files

DevinCodes commented 4 years ago

Hey @westonganger , thank you for reporting this!

Could you please show the contents of your config.rb file, along with the structure of your directory so we can see what's going on? Any other steps to reproduce would be super helpful as well.

Thank you in advance!

westonganger commented 4 years ago

Okay so here is the relevant snippet from my config:

register_data_dirs([
  'app/data'
])

I think this code is causing it to fail. See line 100 below.

https://github.com/algolia/frontman/blob/f73d660e2cacc7b1eada5f4453a0b118b6a945ef/lib/frontman/app.rb#L98-L104

Apparently the name of the documented data variable is set by the name of the folder to_sym which in this case would be :'app/data'

DevinCodes commented 4 years ago

You're right, having the directory nested makes it fail indeed. This is a bug, I'll try fix this soon, or feel free to take it on if you'd like 👍

westonganger commented 4 years ago

Ok I have created a PR for this. We also need to clearly document that the variable names are set by the data dir name.