- [x] do laundry
{
"metadata": {
"tasks": [{ "description": "do laundry", "checked": true }]
}
}
---
title: Example Post
date: 2023-01-01
---
# Content
{
"metadata": {
"title": "Example Post",
"date": "2023-01-01"
}
}
---
tags: frontmatter_tag_1, frontmatter_tag_2
---
# Some heading
#body_tag
Lorem ipsum #tag1 #tag2 #tag3
{
"metadata": {
"tags": ["frontmatter_tag_1", "frontmatter_tag_2"]
},
"tags": ["body_tag", "frontmatter_tag_1", "frontmatter_tag_2"]
}
const addTitle = (fileInfo, ast) => {
const headerNode = ast.children.find((node) => node.type === "heading");
const title = headerNode
? headerNode.children.map((child) => child.value).join("")
: "";
fileInfo.title = title;
};
client.indexFolder({
folderPath: "PATH_TO_FOLDER",
customConfig: { computedFields: [addTitle] },
});
Our vision
Imagine a world where Markdown isn't just text – it's a source of structured and unstructured data. With MarkdownDB, we aim to balance the simplicity and accessibility of writing in Markdown with the ability to query your collection of markdown files like a database – think get me all files "with type Blog" or "all documents created in the last week" or "all documents with 'hello world' in the title" or find "all tasks (i.e. - [ ]) in all documents".
For example, your blog posts. Each file can have a YAML frontmatter header with metadata like title, date, tags, etc.
---
title: My first blog post
date: 2021-01-01
tags: [a, b, c]
author: John Doe
---
# My first blog post
This is my first blog post.
I'm using MarkdownDB to manage my blog posts.
Use the npm mddb package to index Markdown files into an SQLite database. This will create a markdown.db file in the current directory.
# npx mddb <path-to-folder-with-your-md-files>
npx mddb ./blog
SELECT files.*
FROM files
INNER JOIN file_tags ON files._id = file_tags.file
WHERE file_tags.tag = 'a'
Use our Node API to query your data for your blog, wiki, docs, digital garden, or anything you want!
import { MarkdownDB } from "mddb";
const client = new MarkdownDB({
client: "sqlite3",
connection: { filename: "markdown.db" },
});
const mddb = await client.init();
const blogFiles = await mddb.getFiles({
frontmatter: { draft: false },
});
MarkdownDB released!
First version of the package released under @flowershow/markdowndb with basic functionalities, like indexing files into an SQLite database, extracting frontmatter data and basic JS API.
Version 0.1.0
We added support for extracting and querying forward links and backlinks.
Version 0.2.0
We fixed some annoying bugs and renamed package from @flowershow/markdowndb to just mddb.
Version 0.3.0
Support for querying files by frontmatter field values.
Version 0.4.0
Add Tags Extraction from Markdown Content.
Version 0.5.0
Add tasks extraction from files. e.g - [ ] task
Version 0.6.0
Implement JSON output to disk.
Version 1.0.0
Support for custom document types and computed fields.