This is a template that you can customize to create your own data wrangler for your Obsidian database. This is useful for cases in which you need more powerful querying than Dataview, or you need to import/export your data into multiple formats.
- Interact with your Obsidian data like an ORM that is fully type-safe.
- Wraps around front-matter to provide access to both YAML frontmatter and Markdown text content.
- Write your own parsing logic - the returned data structure doesn't have to match your Obsidian schema 1-to-1
- Most of the core functionality and (minimal) state is contained within a Singleton class - no need to manage instantiation, just script away!
- Auto-caches repeated data requests.
- Uses dependency injection, making the code readable, testable, and super easy to modify.
git clone https://github.com/FOSSforlife/obsidian-helper-template
cd obsidian-helper-template && npm i
- Edit
config.ts
with your vault's details. - Edit the code inside
features/
to match your vault's data structures. - Add some scripts to the
scripts/
folder that make use of the repositories that you've added.
export interface ObsidianFileMetadata {
name: string;
}
export interface ObsidianFile {
attributes: {
file: ObsidianFileMetadata;
} & Record<string, any>;
body: string;
}
// This is a Singleton class. Access it ONLY using ObsidianService.instance
export declare class ObsidianService {
readdir(folder: string): Promise<any>;
readFile(filePath: string): Promise<ObsidianFile>;
writeFile(filePath: string, data: ObsidianFile): Promise<any>;
static get instance(): ObsidianService;
}
- More Markdown utilities for parsing the actual body into sections, todo lists, tables, and bullet points
- Code generation to create interfaces and repositories from your Markdown schema
- One-command install using
npm create
ornpx
- Make caching toggleable (in case someone is using this in a stateful environment, as opposed to the command line)