Documentation
¶
Overview ¶
Package links provides functionality for classifying, resolving, and fixing links in markdown documents. It handles temporal links (Yesterday/Tomorrow), cross-reference links (Journal/Standup), and can resolve stale date links to point to actual existing files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClassifiedLink ¶
type ClassifiedLink struct {
// Link is the original markdown link
Link markdown.Link
// Type is the classified type of the link
Type LinkType
// TargetNoteType is the type of note this link points to (if applicable)
TargetNoteType string
}
ClassifiedLink represents a link with its classification
func FilterByType ¶
func FilterByType(links []ClassifiedLink, linkType LinkType) []ClassifiedLink
FilterByType filters classified links by type
func (*ClassifiedLink) NeedsFixing ¶
func (l *ClassifiedLink) NeedsFixing() bool
NeedsFixing returns true if a classified link might need fixing Temporal and cross-reference links with date destinations are candidates for fixing
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
Classifier classifies markdown links
func NewClassifier ¶
func NewClassifier(cfg *config.Config) *Classifier
NewClassifier creates a new link classifier
func (*Classifier) Classify ¶
func (c *Classifier) Classify(link markdown.Link) ClassifiedLink
Classify classifies a single link
func (*Classifier) ClassifyAll ¶
func (c *Classifier) ClassifyAll(links []markdown.Link) []ClassifiedLink
ClassifyAll classifies all links in a list
type LinkType ¶
type LinkType string
LinkType represents the type/purpose of a link
const ( // LinkTypeTemporalPrevious represents links to previous entries (Yesterday, Previous, etc.) LinkTypeTemporalPrevious LinkType = "temporal_previous" // LinkTypeTemporalNext represents links to next entries (Tomorrow, Next, etc.) LinkTypeTemporalNext LinkType = "temporal_next" // LinkTypeCrossReference represents links between different note types (Journal <-> Standup) LinkTypeCrossReference LinkType = "cross_reference" // LinkTypeExternal represents external URLs LinkTypeExternal LinkType = "external" // LinkTypeOther represents other types of links (wiki links, etc.) LinkTypeOther LinkType = "other" )
type ResolvedLink ¶
type ResolvedLink struct {
// Classified is the classified link
Classified ClassifiedLink
// ResolvedPath is the actual file path the link should point to (if resolved)
ResolvedPath string
// ResolvedDate is the date of the resolved note
ResolvedDate time.Time
// Error is set if the link couldn't be resolved
Error error
// NeedsUpdate is true if the link destination needs to be updated
NeedsUpdate bool
// SuggestedDestination is the suggested new destination for the link
SuggestedDestination string
}
ResolvedLink represents a link with its resolved target
func FilterNeedsUpdate ¶
func FilterNeedsUpdate(resolved []ResolvedLink) []ResolvedLink
FilterNeedsUpdate filters resolved links to only those that need updating
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves links to actual file paths
func NewResolver ¶
func NewResolver(cfg *config.Config, currentDate time.Time, currentNoteType notes.NoteType) *Resolver
NewResolver creates a new link resolver currentDate is the date of the current note being processed currentNoteType is the type of the current note (journal or standup)
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(classified ClassifiedLink) ResolvedLink
Resolve resolves a classified link to its actual target
func (*Resolver) ResolveAll ¶
func (r *Resolver) ResolveAll(classified []ClassifiedLink) []ResolvedLink
ResolveAll resolves all classified links