inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.13k stars 101 forks source link

Possible to get liquid page values in template #326

Closed xubeisi closed 3 years ago

xubeisi commented 3 years ago

hi, @inukshuk It's a awesome plugin you guys developed!

Recently, I modified the template a little so they could automatically underline the defined authors.

Such as image

code example here site.scholar.first_names_team

my goal is each page could use the same bib template but highlight different authors.

However, it doesn't seems possible to pass page values to in template such as _layouts/bib.html. I tried read the code, seems only "entry" stored data.

thus wondering for a query like

{% bibliography -f {{ bibfile }} --template bib -q @*[year={{y}}]* %}

is it possible to pass some parameters like

{% bibliography -f {{ bibfile }} --template bib -q @*[year={{y}}]* --values "first_authors_to_highlight:Author1,Author2" %}

then in template.html, {{ site.scholar.first_authors_to_highlight }} would be "Author1,Author2"

Thank you!

inukshuk commented 3 years ago

Good question!

There's currently no tag parameter we specifically pass-through. However, you mentioned you would like set these parameters per page, so I was curious if the page's front-matter config is accessible by the templates. It currently isn't, but it would be easy to expose it (see commit above). Would that work for you?

xubeisi commented 3 years ago

Good question!

There's currently no tag parameter we specifically pass-through. However, you mentioned you would like set these parameters per page, so I was curious if the page's front-matter config is accessible by the templates. It currently isn't, but it would be easy to expose it (see commit above). Would that work for you?

hi, Sylvester, that's great! I thought that's not possible thus I was seeking for solutions by pass variables. What you proposed were much better if it could be done. Thank you for considering that!!

inukshuk commented 3 years ago

The test passes fine, so this should work OK. I'll make a point release for you to try out.

inukshuk commented 3 years ago

Landed in 6.8.1

xubeisi commented 3 years ago

@inukshuk Awesome, it works! thank you very much! I really appreciated your fast implementation!