Search code examples
templatesmetadatadocpad

More complex docpad metadata


I'm new to docpad and a lot of the things which it's based upon, therefore sorry if this question might seem a bit dumb. So far docpad is the most designer-friendly one of the recent static site builder out there, that's why I even made it until here :) Thanks for the amazing documentation!

What I'd like to achieve is the following:

  • setting up pages in a way that I can access different sections via the template (e.g. paragraph 1, table 1, paragraph 2)
  • having a template which allows me to change the structure/order of the content of those pages (eg moving around the paragraphs on all of them by changing the template)

The metadata section sounded good for that, but it does not allow any markup languages in there, right? So where can I define those different "paragraphs" and how can I access them via the template?

Thanks, Philipp


Solution

  • So you could do the following:

    --- cson
    someContent: """
        # h1
        p1
        """
    ---
    
    <%- @document.someContent %>
    

    And name the file blah.html.md.eco so render the eco first which wil inject someContent, then it will render with markdown, rendering someContent.

    We also had --- cson to say use CSON to parse the meta data rather than the standard YAML parser. I find CSON easier to write for more advanced things and multi-line inputs.

    Alternatively for the rendering aspect, you can use the text plugin to specify how pieces of content should be rendered like so:

    --- cson
    someContent: """
        <t render="md">
            # h1
            p1
        </t>
        """
    ---
    
    <%- @document.someContent %>