Go library implementing the mdbase specification v0.2.0 — a standard for treating folders of markdown files as typed, queryable data collections.
This implementation targets conformance to mdbase Level 3 (Querying), which includes:
- Level 1 — Basic CRUD: Collection recognition, type loading, file matching, frontmatter validation, and create/read/update/delete operations.
- Level 2 — File Operations: File renaming with automatic reference updates.
- Level 3 — Querying: Query execution using an expression language for filtering and sorting, computed fields, and body content filtering.
The goal for this library is to reach full Level 6 (Migrations) conformance.
go get github.com/dstotijn/go-mdbasepackage main
import (
"fmt"
"log"
"github.com/dstotijn/go-mdbase"
)
func main() {
c, err := mdbase.Open("./my-collection")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Collection: %s\n", c.Config().Name)
fmt.Printf("Types: %d\n", len(c.Types()))
fmt.Printf("Records: %d\n", len(c.Records()))
for _, r := range c.Records() {
fmt.Printf(" %s\n", r.Path)
}
}A collection is a directory containing an mdbase.yaml config file, optional
type definitions in _types/, and markdown files with YAML frontmatter:
my-collection/
├── mdbase.yaml
├── _types/
│ └── task.md
├── tasks/
│ ├── fix-bug.md
│ └── write-docs.md
└── notes/
└── idea.md