wiki

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

type Page struct {
	// contains filtered or unexported fields
}

Page represents a single page in a wiki. Pages form a tree via children, and are identified by slug.

func NewPage

func NewPage(slug, title, content string, position int, children []Page) Page

NewPage creates a new Page.

func (Page) Children

func (p Page) Children() []Page

Children returns the child pages.

func (Page) Content

func (p Page) Content() string

Content returns the markdown content of this page.

func (Page) Position

func (p Page) Position() int

Position returns the sort order of this page among siblings.

func (Page) Slug

func (p Page) Slug() string

Slug returns the URL-safe identifier for this page.

func (Page) Title

func (p Page) Title() string

Title returns the display title of this page.

type RewrittenContent

type RewrittenContent struct {
	// contains filtered or unexported fields
}

RewrittenContent is a value object that holds markdown content with internal wiki links rewritten to use full hierarchical API paths.

func NewRewrittenContent

func NewRewrittenContent(content string, pathIndex map[string]string, urlPrefix string, suffix string) RewrittenContent

NewRewrittenContent rewrites markdown links in content. Links whose target is a known slug are replaced with urlPrefix + "/" + fullPath + suffix. Absolute URLs and unknown slugs are left unchanged.

func (RewrittenContent) String

func (r RewrittenContent) String() string

String returns the rewritten markdown content.

type Wiki

type Wiki struct {
	// contains filtered or unexported fields
}

Wiki represents a complete wiki generated from a repository. It is a value object constructed by deserializing an enrichment's content.

func NewWiki

func NewWiki(pages []Page) Wiki

NewWiki creates a Wiki from a list of pages.

func ParseWiki

func ParseWiki(content string) (Wiki, error)

ParseWiki deserializes a wiki from JSON content stored in an enrichment.

func (Wiki) JSON

func (w Wiki) JSON() (string, error)

JSON serializes the wiki to JSON for storage in enrichment content.

func (Wiki) Page

func (w Wiki) Page(slug string) (Page, bool)

Page finds a single page by slug, searching the entire tree. Returns the page and true if found, or an empty page and false otherwise.

func (Wiki) PageByPath

func (w Wiki) PageByPath(path string) (Page, bool)

PageByPath resolves a page by its hierarchical path (e.g. "architecture/database-layer"). It walks the tree level by level, splitting on "/".

func (Wiki) Pages

func (w Wiki) Pages() []Page

Pages returns the full page tree.

func (Wiki) PathIndex

func (w Wiki) PathIndex() map[string]string

PathIndex returns a map from slug to hierarchical path for every page. For example, a child page "database-layer" under "architecture" maps to "architecture/database-layer". Top-level pages map to their slug.

Jump to

Keyboard shortcuts

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