Documentation
¶
Overview ¶
Package notes is the core data layer: Note type, parser, Obsidian vault detector, file store, and link graph.
Index ¶
- Variables
- func ExtractInlineTags(content string) []string
- func ExtractWikilinks(content string) []string
- func IsObsidianFile(path string) bool
- func ParseFrontmatter(raw string) (frontmatter map[string]interface{}, body string, err error)
- func SortNotes(notes []*Note, by string)
- func ToMarkdown(note *Note) string
- type Graph
- type GraphNode
- type ListOptions
- type Note
- type ObsidianSettings
- type ObsidianVault
- type Store
- func (s *Store) Count() (int, error)
- func (s *Store) Create(folder string, title string, tags []string, content string) (*Note, error)
- func (s *Store) Delete(idOrTitle string) error
- func (s *Store) DetectPARAFolders() []string
- func (s *Store) ExtraFolders() []string
- func (s *Store) Get(idOrTitle string) (*Note, error)
- func (s *Store) List(opts ListOptions) ([]*Note, error)
- func (s *Store) Move(idOrTitle string, targetFolder string) error
- func (s *Store) Reload(note *Note) (*Note, error)
- func (s *Store) RenderTemplate(templateName string, title string) (string, error)
- func (s *Store) Tags() (map[string]int, error)
- func (s *Store) Update(note *Note) error
- type TemplateData
Constants ¶
This section is empty.
Variables ¶
var ErrNoteNotFound = fmt.Errorf("note not found")
ErrNoteNotFound se devuelve cuando no encontramos la nota.
Functions ¶
func ExtractInlineTags ¶
ExtractInlineTags finds #tag patterns outside fenced code blocks and URLs. Returns deduplicated tag names without the leading '#'.
func ExtractWikilinks ¶
ExtractWikilinks returns deduplicated [[wikilink]] targets from content. For [[target|display]] only the target part is returned.
func IsObsidianFile ¶
IsObsidianFile reports whether path lives inside a .obsidian/ or .trash/ folder and should be skipped during vault walks.
func ParseFrontmatter ¶
ParseFrontmatter splits raw markdown into a YAML frontmatter map and body. Returns an empty map and the full content when no frontmatter is present.
func ToMarkdown ¶
ToMarkdown serializes a Note to markdown with YAML frontmatter. Always includes id, title, tags, created, updated plus any Extra fields.
Types ¶
type Graph ¶
Graph is an in-memory bidirectional link graph built from a slice of Notes.
func BuildGraph ¶
BuildGraph constructs a bidirectional link graph from a slice of notes.
func (*Graph) MostConnected ¶
MostConnected returns the top limit nodes by total connections (links + backlinks). A limit ≤ 0 returns all nodes.
type GraphNode ¶
type GraphNode struct {
Title string
Path string
Tags []string
Links []string // outgoing [[wikilinks]]
Backlinks []string // notes that link to this one
}
GraphNode represents a single note in the link graph.
type ListOptions ¶
type ListOptions struct {
Tags []string // Filter by tags (AND logic — note must have ALL tags)
Query string // Case-insensitive substring match against note title
Limit int // Maximum number of results; 0 means no limit
SortBy string // "updated" (default), "created", or "title"
}
ListOptions controla cómo filtramos y paginamos las notas.
type Note ¶
type Note struct {
ID string // UUID (e.g. "a1b2c3d4-...")
Title string // From frontmatter or first H1
Path string // Absolute path to the .md file
RelPath string // Relative path from vault root (set by caller)
Content string // Body content (after frontmatter)
RawContent string // Full raw file content
Tags []string // From frontmatter + inline #tags
Links []string // [[wikilink]] targets (note titles)
BlockRefs []string // ^block-id references
Aliases []string // Obsidian aliases field
Created time.Time
Updated time.Time
Extra map[string]interface{} // Extra frontmatter fields preserved
}
Note represents a single markdown note in the vault.
func ParseContent ¶
ParseContent parses raw markdown (with optional YAML frontmatter) and returns a Note. path is used for title fallback and Note.Path.
type ObsidianSettings ¶
type ObsidianSettings struct {
NewFileLocation string `json:"newFileLocation"` // "root", "folder", "current"
DefaultLocation string `json:"newFileFolderPath"` // folder for new notes
AttachmentFolder string `json:"attachmentFolderPath"` // attachment storage path
UseMarkdownLinks bool `json:"useMarkdownLinks"` // true → [text](path)
}
ObsidianSettings holds a subset of Obsidian's app.json relevant to note creation and attachment handling.
type ObsidianVault ¶
type ObsidianVault struct {
Path string // absolute path to vault root
IsObsidian bool // true if .obsidian/ was found
Settings ObsidianSettings // parsed from .obsidian/app.json
}
ObsidianVault describes a detected (or absent) Obsidian vault.
func DetectObsidianVault ¶
func DetectObsidianVault(vaultPath string) (*ObsidianVault, error)
DetectObsidianVault checks vaultPath for a .obsidian/ directory. When found it reads app.json for user settings. Missing or malformed settings files are silently ignored — the caller always gets a valid struct back.
func (*ObsidianVault) NoteLocation ¶
func (v *ObsidianVault) NoteLocation(_ string) string
NoteLocation returns the directory where a new note should be created, based on Obsidian's newFileLocation setting. Falls back to the vault root when the "current" mode is requested (it requires editor context we don't have).
type Store ¶
type Store struct {
VaultPath string // Absolute path to the vault root
Vault *ObsidianVault // Detected Obsidian metadata (may be non-Obsidian)
}
Store maneja las notas en disco a partir de la raíz del vault.
func (*Store) DetectPARAFolders ¶
DetectPARAFolders revisa si el usuario usa carpetas numeradas (ej. "1. Projects") o normales ("Projects").
func (*Store) ExtraFolders ¶
ExtraFolders devuelve las carpetas raíz que no son del método PARA ni del sistema.
func (*Store) Get ¶
Get busca primero por UUID, luego por título y por último por nombre de archivo.
func (*Store) List ¶
func (s *Store) List(opts ListOptions) ([]*Note, error)
List recorre el vault, lee los .md y devuelve los resultados filtrados y ordenados.
func (*Store) RenderTemplate ¶
RenderTemplate looks for a template file by name (either in .obsidian/templates/ or templates/), and executes it with the provided title and current date.
type TemplateData ¶
TemplateData holds the variables that can be used inside a template.