model

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 model is a placeholder for Obsite domain models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCanonicalLookupNames

func BuildCanonicalLookupNames(values []string) (map[string]string, map[string][]string)

BuildCanonicalLookupNames returns the basename-only canonical fallback table plus any canonical collisions that must refuse fallback.

func BuildCanonicalLookupPaths

func BuildCanonicalLookupPaths(values []string) (map[string]string, map[string][]string)

BuildCanonicalLookupPaths returns the canonical-path fallback table plus any canonical collisions that must refuse fallback.

func BuildExactLookupPaths

func BuildExactLookupPaths(values []string) map[string]string

BuildExactLookupPaths returns the normalized exact-path lookup table for the provided vault-relative paths.

func CanonicalResourceLookupName

func CanonicalResourceLookupName(value string) string

CanonicalResourceLookupName returns the shared canonical form used for basename-only resource lookup.

func CanonicalResourceLookupPath

func CanonicalResourceLookupPath(value string) string

CanonicalResourceLookupPath returns the shared canonical form used for Unicode-stable resource and asset path lookup.

func LessRecentNote

func LessRecentNote(left *Note, right *Note) bool

LessRecentNote orders notes by published time descending, then slug ascending.

func NormalizeTagName

func NormalizeTagName(value string) string

NormalizeTagName applies the shared canonical tag contract used by indexing and rendering.

Types

type Asset

type Asset struct {
	SrcPath  string
	DstPath  string
	RefCount int
}

Asset represents a non-Markdown resource referenced by notes.

type BacklinkEntry

type BacklinkEntry struct {
	Title string
	URL   string
}

BacklinkEntry represents a backlink listed on a note page.

type Breadcrumb struct {
	Name string
	URL  string
}

Breadcrumb represents one navigation breadcrumb item.

type EmbedRef

type EmbedRef struct {
	Target   string
	Fragment string
	IsImage  bool
	Width    int
	Line     int
	Offset   int
}

EmbedRef records an embed reference discovered during parsing.

type Frontmatter

type Frontmatter struct {
	Title       string
	Description string
	Date        time.Time
	Updated     time.Time
	Tags        []string
	Aliases     []string
	Publish     *bool
	Slug        string
	Extra       map[string]any
}

Frontmatter holds the supported YAML frontmatter fields plus unknown extras.

type Heading

type Heading struct {
	Level int
	Text  string
	ID    string
}

Heading captures a heading extracted from Markdown.

type ImageRef

type ImageRef struct {
	RawTarget string
	Line      int
	Offset    int
}

ImageRef records a standard Markdown image reference discovered during parsing.

type LinkGraph

type LinkGraph struct {
	Forward  map[string][]string
	Backward map[string][]string
}

LinkGraph stores forward and backward note relationships.

type LinkRef

type LinkRef struct {
	// RawTarget is captured from the source wikilink during AST extraction.
	RawTarget string
	// ResolvedRelPath is filled on render-time link copies once RawTarget matches a note.
	ResolvedRelPath string
	Display         string
	Fragment        string
	Line            int
	Offset          int
}

LinkRef records an outbound wikilink across extraction and resolution phases.

type Note

type Note struct {
	RelPath      string
	Frontmatter  Frontmatter
	LastModified time.Time

	Slug            string
	Aliases         []string
	Tags            []string
	Headings        []Heading
	HeadingSections map[string]SectionRange

	RawContent    []byte
	BodyStartLine int
	HTMLContent   string
	Summary       string

	OutLinks  []LinkRef
	Embeds    []EmbedRef
	ImageRefs []ImageRef

	HasMath    bool
	HasMermaid bool
}

Note describes a Markdown note discovered in a vault.

func (*Note) PublishedAt

func (n *Note) PublishedAt() time.Time

PublishedAt returns the best available article timestamp for this note.

type NoteSummary

type NoteSummary struct {
	Title        string
	Summary      string
	URL          string
	Date         time.Time
	LastModified time.Time
	Tags         []TagLink
}

NoteSummary is the compact note representation used in list pages.

type OpenGraph

type OpenGraph struct {
	Title       string
	Description string
	URL         string
	Image       string
	Type        string
}

OpenGraph contains page-level Open Graph metadata.

type PageData

type PageData struct {
	Kind        PageKind
	Site        SiteConfig
	SiteRootRel string

	Title       string
	TitleID     string
	Description string
	Slug        string
	Canonical   string
	RelPath     string

	Content         template.HTML
	TOC             []TOCEntry
	Date            time.Time
	LastModified    time.Time
	ReadingTime     string
	WordCount       int
	Tags            []TagLink
	Backlinks       []BacklinkEntry
	RelatedArticles []RelatedArticle
	HasMath         bool
	HasMermaid      bool
	HasSearch       bool
	HasCustomCSS    bool
	HasRSS          bool

	TagName        string
	TagNotes       []NoteSummary
	ChildTags      []TagLink
	FolderPath     string
	FolderChildren []NoteSummary

	RecentNotes   []NoteSummary
	TimelineNotes []NoteSummary
	Pagination    *PaginationData
	SidebarTree   []SidebarNode

	OG          OpenGraph
	TwitterCard string
	JSONLD      template.JS

	Breadcrumbs []Breadcrumb
}

PageData is the shared template contract for all rendered pages.

type PageKind

type PageKind string

PageKind identifies the template variant represented by PageData.

const (
	PageNote     PageKind = "note"
	PageTag      PageKind = "tag"
	PageIndex    PageKind = "index"
	Page404      PageKind = "404"
	PageFolder   PageKind = "folder"
	PageTimeline PageKind = "timeline"
)
type PageLink struct {
	Number int
	URL    string
}

PageLink represents a numbered pagination destination.

type PaginationConfig

type PaginationConfig struct {
	PageSize int
}

PaginationConfig controls list-page pagination behavior.

type PaginationData

type PaginationData struct {
	CurrentPage int
	TotalPages  int
	PrevURL     string
	NextURL     string
	Pages       []PageLink
}

PaginationData contains page-navigation metadata for list pages.

type PathLookupResult

type PathLookupResult struct {
	Path      string
	Ambiguous []string
}

PathLookupResult describes an exact or canonical resource lookup.

Path is populated when lookup succeeds. Ambiguous is populated when canonical fallback matched multiple vault-relative paths and lookup intentionally refuses to choose a winner.

type PopoverConfig

type PopoverConfig struct {
	Enabled bool
}

PopoverConfig controls internal-link preview generation.

type RSSConfig

type RSSConfig struct {
	Enabled    bool
	EnabledSet bool
}

RSSConfig controls RSS feed emission.

type RelatedArticle

type RelatedArticle struct {
	Title   string
	URL     string
	Summary string
	Score   float64
	Tags    []TagLink
}

RelatedArticle contains precomputed related-content metadata for a note page.

type RelatedConfig

type RelatedConfig struct {
	Enabled bool
	Count   int
}

RelatedConfig controls related-article generation.

type SearchConfig

type SearchConfig struct {
	Enabled         bool
	PagefindPath    string
	PagefindVersion string
}

SearchConfig configures optional Pagefind-based search output.

type SectionRange

type SectionRange struct {
	StartOffset int
	EndOffset   int
}

SectionRange identifies a source slice within Note.RawContent.

type SidebarConfig

type SidebarConfig struct {
	Enabled bool
}

SidebarConfig controls the optional collapsible sidebar file tree.

type SidebarNode

type SidebarNode struct {
	Name     string        `json:"name"`
	URL      string        `json:"url"`
	IsDir    bool          `json:"isDir"`
	IsActive bool          `json:"isActive"`
	Children []SidebarNode `json:"children,omitempty"`
}

SidebarNode represents one node in the rendered sidebar file tree.

type SiteConfig

type SiteConfig struct {
	Title             string
	BaseURL           string
	Author            string
	Description       string
	Language          string
	DefaultPublish    bool
	DefaultPublishSet bool
	DefaultImg        string
	Themes            map[string]ThemeConfig
	DefaultTheme      string
	ActiveThemeName   string
	ThemeRoot         string
	CustomCSS         string
	Search            SearchConfig
	Pagination        PaginationConfig
	Sidebar           SidebarConfig
	Popover           PopoverConfig
	Related           RelatedConfig
	RSS               RSSConfig
	Timeline          TimelineConfig

	KaTeXCSSURL        string
	KaTeXJSURL         string
	KaTeXAutoRenderURL string
	MermaidJSURL       string
}

SiteConfig is the stable site-level configuration contract shared across packages. URL-like fields intentionally remain plain strings so html/template keeps contextual escaping. DefaultPublishSet and RSS.EnabledSet disambiguate explicit false from shared product defaults, which resolve to true when unset.

func (SiteConfig) EffectiveDefaultPublish

func (cfg SiteConfig) EffectiveDefaultPublish() bool

EffectiveDefaultPublish returns the resolved publish policy for notes that do not set frontmatter publish.

func (SiteConfig) EffectiveRSSEnabled

func (cfg SiteConfig) EffectiveRSSEnabled() bool

EffectiveRSSEnabled returns the resolved RSS policy for the site.

type TOCEntry

type TOCEntry struct {
	Text     string
	ID       string
	Children []TOCEntry
}

TOCEntry represents a nested table-of-contents item for a note page.

type Tag

type Tag struct {
	Name  string
	Slug  string
	Notes []string
}

Tag represents a tag and the notes currently associated with it.

type TagLink struct {
	Name string
	Slug string
	URL  string
}

TagLink represents a tag link emitted into templates.

type ThemeConfig

type ThemeConfig struct {
	Root string
}

ThemeConfig describes a named build-time theme root.

type TimelineConfig

type TimelineConfig struct {
	Enabled    bool
	AsHomepage bool
	Path       string
}

TimelineConfig controls the recent-notes timeline page.

type UnpublishedLookup

type UnpublishedLookup struct {
	Notes       map[string]*Note
	NoteByName  map[string][]*Note
	AliasByName map[string][]*Note
}

UnpublishedLookup retains enough metadata for later path/name/alias resolution after unpublished notes are removed from the public lookup tables.

type VaultIndex

type VaultIndex struct {
	AttachmentFolderPath string
	Notes                map[string]*Note
	NoteBySlug           map[string]*Note
	NoteByName           map[string][]*Note
	AliasByName          map[string][]*Note
	Tags                 map[string]*Tag
	Assets               map[string]*Asset
	AssetLookup          map[string]string
	Resources            map[string]string
	ResourceBaseNames    map[string]string
	Unpublished          UnpublishedLookup
	// contains filtered or unexported fields
}

VaultIndex is the immutable handoff between pass 1 indexing and pass 2 rendering. Pass 2 must clone any per-render note state instead of mutating notes held here.

Exact asset and resource sets remain the source of truth. Derived canonical fallback tables are populated eagerly by constructors like BuildIndex and are also rebuilt lazily on first lookup so tests and callers cannot observe a half-initialized handoff object.

func (*VaultIndex) HasResource

func (idx *VaultIndex) HasResource(relPath string) bool

func (*VaultIndex) HasResourceBaseName

func (idx *VaultIndex) HasResourceBaseName(name string) bool

func (*VaultIndex) LookupAssetPath

func (idx *VaultIndex) LookupAssetPath(relPath string) PathLookupResult

func (*VaultIndex) LookupResourceBaseName

func (idx *VaultIndex) LookupResourceBaseName(name string) PathLookupResult

func (*VaultIndex) LookupResourcePath

func (idx *VaultIndex) LookupResourcePath(relPath string) PathLookupResult

func (*VaultIndex) ResolveAssetPath

func (idx *VaultIndex) ResolveAssetPath(relPath string) string

func (*VaultIndex) ResolveResourceBaseName

func (idx *VaultIndex) ResolveResourceBaseName(name string) string

func (*VaultIndex) ResolveResourcePath

func (idx *VaultIndex) ResolveResourcePath(relPath string) string

func (*VaultIndex) SetAssets

func (idx *VaultIndex) SetAssets(assets map[string]*Asset)

func (*VaultIndex) SetResources

func (idx *VaultIndex) SetResources(resourceFiles []string)

Jump to

Keyboard shortcuts

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