Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set up multiple content areas in metalsmith?

I have a very simple use case for metalsmith that doesn't seem to be covered by any readily available documentation.

In my index.html I want multiple content areas:

<!-- in my index html -- a single page landing site -->
<body>
  <section id="about">
     {{{about}}}
  </section>
  <section id="faq">
     {{{faq}}}
  </section>
...

And I want the contents for about and faq to come from markdown files. I'm happy to change how my files are organised/marked up.

I just can't figure out which plugins to use to make it work, everything seems geared towards generating one output file per source file.

The plugins that seem they would work (metalsmith-in-place and metalsmith-layouts) tell you to come to SO for more elaborate examples, so here we are!

like image 546
andyhasit Avatar asked Mar 13 '23 03:03

andyhasit


1 Answers

I created a fork for metalsmith-markdown:

https://github.com/DKhalil/metalsmith-markdown

You can add sections in your markdown files like this:

Markdown text here
---
section: SECTION_NAME
---
Markdown text here

The second markdown part would be available under the variable SECTION_NAME in the template file, the first one still under {{ contents }}

like image 72
Dask Avatar answered Apr 27 '23 23:04

Dask