fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
321 stars 50 forks source link

Question for create md files from extra vars #131

Closed alanlivio closed 2 years ago

alanlivio commented 2 years ago

I know that mkdcos-macros-plugin enable the use of the extra variables from the mkdocs.yaml

extra:
   data_for_page1
   data_for_page2

Such variables can be in existing markdown files, e.g., page.md uses extra.data_for_page1 and page2.md uses extra.data_for_page2.

I am wondering if it is possible to use such variables to make mkdcos create the page1.md/page2.md files itself.

fralau commented 2 years ago

You mean, dynamically generating new markdown pages? 🤔

Interesting idea. Is the number of pages variable or static? Could you perhaps elaborate on your use case?

alanlivio commented 2 years ago

You mean, dynamically generating new markdown pages? 🤔

Yes. But defined from some yaml.

Interesting idea. Is the number of pages variable or static? Could you perhaps elaborate on your use case?

I think that may depend on the list of extra variables. Image the next mkdocs.yaml and I will create one page for each given icon/url.

extra:
   new_pages: 
      -  icon: "<url>"
         url: "<url>"
      -  icon: "<url>"
         url: "<url>"
fralau commented 2 years ago

Perhap it is possible to use mkdocs-macros for this, but I had not thought about it.

To avoid "reinventing the wheel", I would look at solutions that have already been implemented. For a dynamic behavior with a variable number pages, I would rather use an existing plugin: awesome pages. Would it do what your are expecting?