Documentation
¶
Overview ¶
Package index builds a session-ID-to-filename index from existing journal files.
Index ¶
- func BuildSessionIndex(journalDir string) map[string]string
- func ExtractFrontmatterField(content, field string) string
- func ExtractSessionID(content string) string
- func LookupSessionFile(index map[string]string, sessionID string) string
- func RenameJournalFiles(journalDir, oldBase, newBase string, numParts int)
- func UpdateNavLinks(journalDir, newBase, oldBase string, numParts int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildSessionIndex ¶
BuildSessionIndex scans journal .md files in journalDir and returns a map of session_id → filename.
Two-pass matching:
- Parse YAML frontmatter for a session_id field (authoritative).
- For files without session_id, extract the last 8 characters before config.ExtMarkdown and treat them as a short ID candidate (migration path for legacy exports).
Parameters:
- journalDir: Path to the journal directory
Returns:
- map[string]string: session ID → filename mapping
func ExtractFrontmatterField ¶
ExtractFrontmatterField extracts a single field value from YAML frontmatter.
Parameters:
- content: Full file content
- field: Field name to extract (e.g. "title")
Returns:
- string: The field value (unquoted), or "" if not found
func ExtractSessionID ¶
ExtractSessionID parses session_id from YAML frontmatter.
Looks for a line matching `session_id: "..."` or `session_id: ...` within the frontmatter block delimited by "---".
Parameters:
- content: Full file content
Returns:
- string: The session ID, or "" if not found
func LookupSessionFile ¶
LookupSessionFile finds the existing filename for a session in the index.
Checks the full session ID first (frontmatter-based match), then falls back to the short ID (filename-based legacy match).
Parameters:
- index: Session index from BuildSessionIndex
- sessionID: Full session UUID
Returns:
- string: Existing filename, or "" if not found
func RenameJournalFiles ¶
RenameJournalFiles renames a journal file (and its multipart siblings) from oldBase to newBase within journalDir.
Handles both the base file (oldBase.md → newBase.md) and multipart files (oldBase-pN.md → newBase-pN.md). Updates internal navigation links in multipart files to reference the new filenames.
Parameters:
- journalDir: Path to the journal directory
- oldBase: Old base filename without extension
- newBase: New base filename without extension
- numParts: Expected number of parts (used for nav link updates)
func UpdateNavLinks ¶
UpdateNavLinks replaces references to oldBase with newBase inside all part files for a session.
Parameters:
- journalDir: Path to the journal directory
- newBase: New base filename without extension
- oldBase: Old base filename without extension
- numParts: Total number of parts
Types ¶
This section is empty.