Skip to content

Content blocks

maneesha edited this page Sep 13, 2024 · 1 revision

Blocks Logic

Blocks templates live in the layouts/partials/blocks/templates/{layout}.html directory where layout matches the block's layout frontmatter key.

Example Text Block in Markdown

---
title: New Page
blocks:
- layout: text
  title: Hello World!
  copy: >-
    Fusce dapibus, tellus ac cursus **commodo**, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Lorem ipsum dolor sit amet, consectetur [adipiscing](/url) elit.

    Yep!
---

Example Text Block template file

At `/layouts/partials/blocks/templates/text.html

{{/*
  blocks/text

  @context Map (.)
    Page (.Page)
    Map (.block)
      String (.title)
      String (.copy)

*/}}
{{ with .block }}
  <h3>{{ .title }}</h3>
  {{ with .copy }}
    <div>
      {{ $.Page.RenderString }}
    </div>
  {{ end }}
{{ end }}
Clone this wiki locally