slug

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: 6 Imported by: 0

Documentation

Overview

Package slug converts human-readable titles into URL-friendly slugs for journal filenames.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanTitle

func CleanTitle(s string) string

CleanTitle normalises a title for storage in YAML frontmatter.

Replaces newlines, tabs, and consecutive whitespace with single spaces, trims the result, and strips the "..." truncation suffix that entity.Session.FirstUserMsg may carry.

Parameters:

  • s: Raw title string

Returns:

  • string: Cleaned title string

func SlugifyTitle

func SlugifyTitle(title string) string

SlugifyTitle converts a human-readable title into a URL-friendly slug.

Lowercases the input, replaces non-alphanumeric characters with hyphens, collapses consecutive hyphens, trims leading/trailing hyphens, and truncates on a word boundary at journal.TitleSlugMaxLen characters.

Parameters:

  • title: Human-readable title string

Returns:

  • string: Slugified string (may be empty if input is empty or all punctuation)

func TitleSlug

func TitleSlug(s *entity.Session, existingTitle string) (slug, title string)

TitleSlug returns the best available slug for a session, following a fallback hierarchy:

  1. existingTitle: enriched title from previously exported frontmatter
  2. s.FirstUserMsg: first user message text
  3. s.Slug: Claude Code's random slug
  4. s.ID[:8]: short ID prefix

The chosen source (except s.Slug and s.ID[:8], which are already slugs) is passed through SlugifyTitle.

Parameters:

  • s: Session to derive the slug from
  • existingTitle: Title from enriched YAML frontmatter (may be empty)

Returns:

  • slug: URL-friendly slug for the filename
  • title: Human-readable title for the H1 heading (empty when falling back to s.Slug or s.ID)

Types

This section is empty.

Jump to

Keyboard shortcuts

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