docsify-mustache / docsify-mustache.github.io

A Docsify plugin that allow preprocessing markdown documents with Mustache template engine.
https://docsify-mustache.github.io
MIT License
16 stars 6 forks source link

Question: using array of values in frontmatter #7

Closed ppipada closed 4 years ago

ppipada commented 4 years ago

I am trying to use an array of values from frontmatter using this plugin. Is there a way I can get the value one at a time?

E.g:

---
tags: [t1, t2, t3]
---

When I access that in md file as {{tags}} it comes as t1,t2,t3. Is there a way I can access each individual value and do something with it? E.g: associate a url with each value.

szkiba commented 4 years ago

Sure, you can access elements by index: {{tags.0}} or {{tags.1}} etc.. Or you can iterate over array:

{{#tags}}

Hey, {{.}}

{{/tags}}
ppipada commented 4 years ago

Thanks a lot. This helps !!

Suggestions:

Observation:

I could add a pull request if you could please guide me on where to add this in docs.

szkiba commented 4 years ago

This is not in docs, because it is mustache usage information, not related directly to plugin functionality... Maybe you should create a blog post about your founding...

ppipada commented 4 years ago

Got it. Thanks.

Reference blog post: https://ppipada.github.io/post/markdown/2020-04-29-docsify-mustache/