slug

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package slug lowercases and NFC-normalizes note slugs, rejects inputs that normalize to empty, and detects slug conflicts using the same canonical form.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidFrontmatterSlug reports an explicit frontmatter slug that normalizes to empty.
	ErrInvalidFrontmatterSlug = errors.New("frontmatter slug normalizes to empty")
	// ErrInvalidFileSlug reports a file stem that normalizes to empty.
	ErrInvalidFileSlug = errors.New("file stem normalizes to empty")
)

Functions

func Canonicalize

func Canonicalize(input string) string

Canonicalize returns the shared lowercase NFC form used by slug generation and note or alias lookup keys.

func DetectConflicts

func DetectConflicts(candidates []Candidate) ([]Conflict, []InvalidSlug)

DetectConflicts returns stable lists of slug conflicts and invalid empty slugs.

func Generate

func Generate(frontmatterSlug *string, relPath string) (string, error)

Generate returns the normalized slug for a note.

If frontmatterSlug is provided, it is authoritative. Otherwise the file stem from relPath is used. Inputs that normalize to empty are rejected.

Types

type Candidate

type Candidate struct {
	Source string
	Slug   string
}

Candidate identifies a source path and the slug assigned to it.

type Conflict

type Conflict struct {
	Slug    string
	Sources []string
}

Conflict reports a slug used by multiple sources.

type InvalidSlug

type InvalidSlug struct {
	Source string
	Slug   string
}

InvalidSlug reports a source whose slug is empty or whitespace-only.

Jump to

Keyboard shortcuts

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