blackstork-io / fabric

An open-source command-line tool for reporting workflow automation and a configuration language for reusable templates. Reporting-as-Code
https://blackstork.io/fabric/
Apache License 2.0
12 stars 0 forks source link

Add constraints for `content.frontmatter` block #116

Closed traut closed 2 months ago

traut commented 3 months ago

Background

At the moment, content.frontmatter blocks in FCL is rendered as a "normal" content block and while it was easy to implement, it is an incorrect behavior. Fabric should implement custom logic for evaluating / rendering content.frontmatter blocks.

Design

For example,


document "test" {

  title = "Test Title"

  content text {
    text = "Normal text"
  }

  content frontmatter "foo" {
    content = {
      fieldA = "valueA",
      fieldB = "valueB",
    }
  }
}

produces the output:

---
fieldA: valueA
fieldB: valueB
---

# Test Title

Normal text
dobarx commented 3 months ago

@traut Maybe it also needs format? Usually frontmatter in markdown can be yaml, toml or json

traut commented 3 months ago

@dobarx it is already in the frontmatter spec -- https://github.com/blackstork-io/fabric/issues/47

dobarx commented 3 months ago

Ahh, forgot I already did that 😄

About content placement. Right now plugin call returns object:

Content {
  Markdown: string
}

Maybe we could return additional parameter for describing a position where to place content. For example: Pos: "start". As for constraints, maybe those could be configured with ContentProvider schema.

traut commented 2 months ago

oh, that's neat! We can start with a simple enum that supports only doc-start (beginning of the document) and as-defined (where the block is defined), and rename / extend when needed

dobarx commented 2 months ago

@traut I think latest changes cover part of this issue. It places frontmatter always on top of the rendered document. Two things remain: