inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.12k stars 102 forks source link

Use page front matter to override configuration #293

Closed anand-bala closed 4 years ago

anand-bala commented 4 years ago

Closes #95

Turns out, this is incredibly simple (2 lines changed! :smile: ). When Jekyll passes a context to the render method, it has a register with the hash :page which bundles all the front matter defined for the given page. To make life easier, the front matter configuration matches the schema for the scholar configuration in _config.yml exactly.

Now, simply merge the configuration hashes!

@inukshuk please let me know if I need to add anything :smile:

inukshuk commented 4 years ago

This great, thanks!

We should definitely mention this in the Readme somewhere, because this should make all kinds of things possible, people have been waiting for.

inukshuk commented 4 years ago

And we ought to add at least one test utilizing this, to guard against regressions.

anand-bala commented 4 years ago

Hey @inukshuk I am not a Ruby developer (I think this PR is the first substantial bit of Ruby I've ever written :laughing:). I would love to be able to write tests for this if you could potentially point me to some resources.

inukshuk commented 4 years ago

I should note that this is certainly not a good project to illustrate Ruby code or testing practices (it's more a collections of hacks), but we do have lots of Cucumber scenarios to test various use cases.

I'm happy to add a test for this, but you're more than welcome if you'd like to take stab at it.

Basically, if you take a look at an existing test you'll see all the necessary syntax: for example, we could add a test just like this one (I would suggesting adding a new file there like config.feature), but setting a different citation style in the page's front matter and then testing for the specific text rendered by using the given style.