Documentation
¶
Index ¶
- func BuildBackreferences(notes []model.Note) []model.Note
- func GetAllNotesFromTree(root *TreeNode) []model.Notedeprecated
- func ParseHashtagLinks(content string) string
- func ParseTagLinksInMetadata(metadata map[string]any) map[string]any
- func ParseWikiLinks(content string, tree *TreeNode) string
- func ParseWikiLinksInMetadata(metadata map[string]any, tree *TreeNode) map[string]anydeprecated
- func ProcessMarkdownLinks(content string) string
- func RemoveCommentBlocks(content string) string
- func SearchNotesByFilename(notes []model.Note, searchQuery string) []model.Note
- func Slugify(text string, options SlugifyOptions) string
- func SlugifyHeading(text string) string
- func SlugifyNote(text string) string
- func SlugifyNoteWithCaseLogic(text, existingSlug string) string
- type HeadingMatch
- type NoteScored
- type NotesService
- func (ns *NotesService) FilterTreeBySearch(query string) *TreeNode
- func (ns *NotesService) GetAllNotes() []model.Note
- func (ns *NotesService) GetHomeSlug(homeNoteSlug string) string
- func (ns *NotesService) GetNote(slug string) (model.Note, bool)
- func (ns *NotesService) GetNotesMap() map[string]model.Note
- func (ns *NotesService) GetTagIndex() TagIndex
- func (ns *NotesService) GetTree() *TreeNode
- func (ns *NotesService) ParseWikiLinks(content string) string
- func (ns *NotesService) ParseWikiLinksInMetadata(metadata map[string]any) map[string]any
- func (ns *NotesService) UpdateData(notesMap *map[string]model.Note, tree *TreeNode, tagIndex TagIndex)
- type SlugifyOptions
- type TagIndex
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildBackreferences ¶
BuildBackreferences analyzes all notes and populates the ReferencedBy field for each note based on wikilinks found in other notes' content
func GetAllNotesFromTree
deprecated
func ParseHashtagLinks ¶
ParseHashtagLinks converts hashtags in content to clickable links It avoids false positives by: 1. Ignoring hashtags inside code blocks (both inline ` and multi-line ```) 2. Only matching hashtags preceded by whitespace or start of line 3. Avoiding hashtags that are part of URLs or other text
func ParseTagLinksInMetadata ¶
ParseTagLinksInMetadata processes tags in metadata and converts them to clickable links
func ParseWikiLinks ¶
ParseWikiLinks transforms [[linktitle]] and [[linktitle|displayname]] into [title](link) format
func ParseWikiLinksInMetadata
deprecated
ParseWikiLinksInMetadata processes wikilinks in metadata values (strings and lists)
Deprecated: Use NotesService.ParseWikiLinksInMetadata(metadata) instead for cleaner syntax. This function remains available for cases where you need to work with a tree directly.
func ProcessMarkdownLinks ¶
ProcessMarkdownLinks removes .md extensions from markdown links before rendering
func RemoveCommentBlocks ¶
RemoveCommentBlocks removes all content between %% markers (inclusive)
func SearchNotesByFilename ¶
SearchNotesByFilename searches notes by filename (title and slug) and returns filtered results This function shows matches in the file name first, folder names second
func Slugify ¶
func Slugify(text string, options SlugifyOptions) string
Slugify converts a string to a URL-friendly slug with configurable options
func SlugifyHeading ¶
SlugifyHeading creates a slug for a heading using heading-specific options
func SlugifyNote ¶
SlugifyNote creates a slug for a note using note-specific options
func SlugifyNoteWithCaseLogic ¶
SlugifyNoteWithCaseLogic creates a slug for a note with special case-preserving logic This function preserves case when creating from titles but converts existing slugs to lowercase
Types ¶
type HeadingMatch ¶
type HeadingMatch struct {
Note model.Note
Heading string // The matched heading text
Level int // 1 for H1, 2 for H2, 3 for H3
Context string // Surrounding text (~150 chars)
LineNum int // Line number in note for potential linking
Score int // Relevance score
}
HeadingMatch represents a match within a note's heading
func SearchNotesByHeadings ¶
func SearchNotesByHeadings(notes []model.Note, searchQuery string, limit int) []HeadingMatch
SearchNotesByHeadings searches for headings (H1-H3) matching the query
type NoteScored ¶
type NotesService ¶
type NotesService struct {
// contains filtered or unexported fields
}
NotesService manages the notes data with thread-safe access
func NewNotesService ¶
func NewNotesService(notesMap *map[string]model.Note, tree *TreeNode, tagIndex TagIndex) *NotesService
NewNotesService creates a new NotesService with the given data
func (*NotesService) FilterTreeBySearch ¶
func (ns *NotesService) FilterTreeBySearch(query string) *TreeNode
FilterTreeBySearch filters the tree to only show nodes matching the search query This is a convenience method that wraps engine.FilterTreeBySearch
func (*NotesService) GetAllNotes ¶
func (ns *NotesService) GetAllNotes() []model.Note
GetAllNotes extracts all notes from the tree structure This is a convenience method that wraps engine.GetAllNotesFromTree
func (*NotesService) GetHomeSlug ¶
func (ns *NotesService) GetHomeSlug(homeNoteSlug string) string
GetHomeSlug determines the home note slug based on priority: 1. The provided homeNoteSlug config value (if it exists in notes) 2. First note in alphabetical order 3. Empty string if no notes exist
func (*NotesService) GetNote ¶
func (ns *NotesService) GetNote(slug string) (model.Note, bool)
GetNote safely retrieves a note by slug
func (*NotesService) GetNotesMap ¶
func (ns *NotesService) GetNotesMap() map[string]model.Note
GetNotesMap returns a thread-safe copy of the notesMap
func (*NotesService) GetTagIndex ¶
func (ns *NotesService) GetTagIndex() TagIndex
GetTagIndex returns the tag index with a read lock
func (*NotesService) GetTree ¶
func (ns *NotesService) GetTree() *TreeNode
GetTree returns the tree with a read lock
func (*NotesService) ParseWikiLinks ¶
func (ns *NotesService) ParseWikiLinks(content string) string
ParseWikiLinks processes wiki-style links in content This is a convenience method that wraps engine.ParseWikiLinks
func (*NotesService) ParseWikiLinksInMetadata ¶
func (ns *NotesService) ParseWikiLinksInMetadata(metadata map[string]any) map[string]any
ParseWikiLinksInMetadata processes wikilinks in metadata values This is a convenience method that wraps engine.ParseWikiLinksInMetadata
func (*NotesService) UpdateData ¶
func (ns *NotesService) UpdateData(notesMap *map[string]model.Note, tree *TreeNode, tagIndex TagIndex)
UpdateData safely updates the service's notesMap, tree, and tagIndex with new data
type SlugifyOptions ¶
type SlugifyOptions struct {
// PreserveSlashes keeps forward slashes in the slug (useful for paths)
PreserveSlashes bool
// URLEncode applies URL encoding to the result
URLEncode bool
// RemoveExtension removes file extensions like .md
RemoveExtension bool
// TrimSlashes removes leading and trailing slashes
TrimSlashes bool
// PreserveCase keeps the original case instead of converting to lowercase
PreserveCase bool
}
SlugifyOptions defines options for slugification behavior
func DefaultHeadingSlugOptions ¶
func DefaultHeadingSlugOptions() SlugifyOptions
DefaultHeadingSlugOptions returns the default options for heading slugification
func DefaultNoteSlugOptions ¶
func DefaultNoteSlugOptions() SlugifyOptions
DefaultNoteSlugOptions returns the default options for note slugification
type TagIndex ¶
TagIndex maps tag names to notes that contain them
func BuildTagIndex ¶
BuildTagIndex creates an index of all tags found in notes Tags can come from: 1. Metadata "tags" field (array of strings) 2. Free text with syntax #[A-Za-z/-]+
func (TagIndex) GetAllTags ¶
GetAllTags returns all unique tags in the index
func (TagIndex) GetNotesWithTag ¶
GetNotesWithTag returns all notes that contain the specified tag
func (TagIndex) GetTagsContaining ¶
GetTagsContaining returns all tags that contain the specified substring
type TreeNode ¶
type TreeNode struct {
Name string `json:"name"` // Display name (folder name or note title)
Path string `json:"path"` // Full path from root
IsFolder bool `json:"isFolder"` // True if this is a folder, false if it's a note
Note *model.Note `json:"note"` // Reference to the note if this is a note node
Children []*TreeNode `json:"children"` // Child nodes (subfolders and notes)
IsOpen bool `json:"isOpen"` // Whether the folder is expanded in the UI
}
TreeNode represents a node in the file tree structure
func FilterTreeBySearch
deprecated
FilterTreeBySearch filters the tree to only show nodes that match the search query
Deprecated: Use NotesService.FilterTreeBySearch(query) instead for cleaner syntax. This function remains available for cases where you need to work with a tree directly.
func FindNoteInTree ¶
FindNoteInTree searches for a note by slug in the tree