larsonjj / generator-yeogurt

A generator for creating static sites. Helps you harness the power of your favorite tools: Pug or Nunjucks, Gulp, ES6/2015, and much more!
MIT License
542 stars 73 forks source link

Access site.data in a module template? #218

Closed saun4app closed 4 years ago

saun4app commented 6 years ago

As far as I can tell, we have access to site.data from pages (e.g., src/page_name/index.nunjucks), but not modules (e.g., _modules/link/link.nunjucks). Is there a way to access site.data from a module?

Thank you.

larsonjj commented 4 years ago

Hey @saun4app,

While you can't access site.data within a nunjucks/jade module directly, you can pass the data to the module if you would like. Here is an example:

{{link.content({
    href: 'https://github.com/larsonjj/generator-yeogurt#yeogurt-generator---',
    text: 'documentation',
    site: site
})}}