index

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package index builds a session-ID-to-filename index from existing journal files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSessionIndex

func BuildSessionIndex(journalDir string) map[string]string

BuildSessionIndex scans journal .md files in journalDir and returns a map of session_id → filename.

Two-pass matching:

  1. Parse YAML frontmatter for a session_id field (authoritative).
  2. 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

func ExtractFrontmatterField(content, field string) string

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

func ExtractSessionID(content string) string

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

func LookupSessionFile(index map[string]string, sessionID string) string

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

func RenameJournalFiles(journalDir, oldBase, newBase string, numParts int)

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(journalDir, newBase, oldBase string, numParts int)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL