Multiple Markdown-text-sections

I’d like to get multiple divs containing Markdown in a single post for a multi-column-post-layout.

e.g. in post1.md -->

+++
title ="post1"

+++
#Headline 1
Text 1

+++
#Headline 2
Text 2

in layout -->

< div >
{{.Content[1]}} --> renders Headline 1 and Text 1
< /div >
< div >
{{.Content[2]}} --> renders Headline 2 and Text 2
< \div >

Well i could wrap parts before/after < hr > with javascript… but that wouldn’t be very nice…

Unfortunately i couldn’t find anything about this “basic?” use-case or i was searching for the wrong things.

Thanks!!

:slight_smile: AK

http://www.w3schools.com/css/css3_multiple_columns.asp

http://caniuse.com/#feat=multicolumn

support is buggy… AND i want the text to break at a specific point. So its more two texts…
:slight_smile: AK

There is an open issue or two about content sections on GitHub, but I wouldn’t be too hopeful about that getting solved anytime soon.

In the meantime …

  • You solve this by being creative with shortcodes with your divs.
  • Or maybe put the columns in to a markdown table …

@halloalexkern

I think I’d need to see what you’re trying to do, but if the content in one section is only headings, you could get clever with the front matter as well. Or you could do something with .Next or . Prev maybe…?

You could use the split template function. Just insert a custom delimiter in the content files at each point where the content should continue in the next column.

Your code would look as follows. I have not tested it but you should get at least a foundation. <split> is our custom delimiter.

{{ $cols := split .Content "<split>" }}

{{ range $cols }}
   <div class="content-column">
   {{ . }}
   </div>
{{ end }}
9 Likes

@digitalcraftsman That is awesome and something I never would have thought of.

@digitalcraftsman Wow, that seems to be thing i was looking for! I’ll going to try it soon and report back. Thanks!! :slight_smile:

Hey

I found this post when searching for a a way to place an image next to text (in a two colomn way), and it helpt me achieve this by creating a partial like this:

{{ $cols := split .RawContent "||" }}

{{ range $cols }}
   <div class="content-column">
   {{ . | markdownify }}
   </div>
{{ end }}

thanks @digitalcraftsman

4 Likes

Trying to do the same thing now, do you have a link to your blog so I can take a look at the implementation? Thanks!

2 Likes