Open talvasconcelos opened 8 years ago
The data
option expects an object which can contain everything that jade (pug) can handle. And it can handle really everything javascript has to offer. So, if you want to pass functions or objects, just do it.
If you set custom template data, see also the readme section about template data. There are some keys that should not be used for custom data, as they are used internally and will propably be overwritten. You should also be aware of how the final template data is merged from different sources (see readme for details).
You can access frontmatter data by simply using the frontmatter key as variable name in jade:
---
mySuperCoolNumber: 12345
---
p= mySuperCoolNumber
The URL of a document is included in the default template data (see readme) and can be accessed via urlPath
in your template.
I'm sorry, there is no built-in method to create an index page or even access a list of all documents. This is a useful feature, indeed. And it should not be hard to implement. If i find some time and mood, i will...
Meanwhile, you can solve this problem pretty easy via template data. You could, for example, glob the files you want to index and build an object or array, which you could add to the data option. To get the final url of an indexed document, you can use the same function to sanitize urls like the plugin does.
Alternatively, you could use a gulp plugin like gulp-foreach to iterate through the files already globbed by gulp and build your index there.
Hi, i managed to get your plugin to work on windows, thanks for your support. Now i'd like to know what can i pass in the data option, and also how can i access for example the full url of the generated post?
Also, is there any way, with your awesome plugin, for me to have an output, json maybe, of the posts, and their frontmatter for being able to to an index page with thumbnails and linking to the post itself...?
P.S: i don't know how to post this as a question instead of an issue...sorry for that!
Thanks Tiago