BrainDB
BrainDB is a library that allows to treat your content as database. It can be used to:
- show backlinks
- resolve wikilinks
- vizualize content as graph
- detect internal broken links
- show recently changed pages
- extract tasks
- implement your own Obsidian Dataview
Related:
Installation
-
Install dependencies
Terminal window pnpm add @braindb/core github-slugger -
Configure Astro
astro.config.mjs export default defineConfig({vite: {optimizeDeps: {exclude: ["fsevents", "@node-rs", "@napi-rs"],},},}); -
Configure BrainDB
src/lib/braindb.mjs import { slug as githubSlug } from "github-slugger";import path from "node:path";import process from "node:process";import { BrainDB } from "@braindb/core";// slug implementation according to Astro// see astro/packages/astro/src/content/utils.tsconst generateSlug = (filePath) => {const withoutFileExt = filePath.replace(new RegExp(path.extname(filePath) + "$"),"");const rawSlugSegments = withoutFileExt.split(path.sep);const slug = rawSlugSegments// Slugify each route segment to handle capitalization and spaces.// Note: using `slug` instead of `new Slugger()` means no slug deduping..map((segment) => githubSlug(segment)).join("/").replace(/\/index$/, "");return slug;};export const bdb = new BrainDB({root: path.resolve(process.cwd(), "src/content/docs"),url: (filePath, _frontmatter) => `${generateSlug(filePath)}/`,git: process.cwd(),});bdb.start();