Documentation
¶
Index ¶
- func ExtractFrontmatter(src string) map[string]string
- func HasLetters(s string) bool
- func InjectHeadingAnchors(html string) string
- func NormalizePagePath(path string) string
- func PageURL(path string) string
- func ParseKeywords(raw string) []string
- func ParseMD(src string, cfg markdown.Config) (html, title string, order int, sidebar string, keywords []string)
- func ParseMDX(src string, cfg markdown.Config) (html, title string, order int, sidebar string, keywords []string)
- func PathToTitle(path string) string
- func SortPages(pages []Page)
- func StripFrontmatter(src string) string
- func StripHTMLTags(s string) string
- type Breadcrumb
- type Config
- type Page
- type SearchEntry
- type SidebarItem
- type TOCItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractFrontmatter ¶
ExtractFrontmatter parses YAML frontmatter from markdown content.
func HasLetters ¶
HasLetters checks if a string contains any letter characters.
func InjectHeadingAnchors ¶
InjectHeadingAnchors post-processes rendered HTML to add anchor link buttons to headings that have id attributes.
func NormalizePagePath ¶
NormalizePagePath strips trailing "/index" from a page path for URL generation. "index" → "" "guides/index" → "guides" "guides/advanced" → "guides/advanced"
func ParseKeywords ¶
ParseKeywords splits a frontmatter `keywords:` value (comma or space separated) into a slice of trimmed keywords.
func ParseMD ¶
func ParseMD(src string, cfg markdown.Config) (html, title string, order int, sidebar string, keywords []string)
ParseMD parses a .md file, extracting frontmatter and rendering markdown.
func ParseMDX ¶
func ParseMDX(src string, cfg markdown.Config) (html, title string, order int, sidebar string, keywords []string)
ParseMDX parses an .mdx file, extracting frontmatter and rendering with JSX support.
func PathToTitle ¶
PathToTitle converts a file path or directory name to a human-readable title.
func SortPages ¶
func SortPages(pages []Page)
SortPages sorts pages by directory, then order, then title.
func StripFrontmatter ¶
StripFrontmatter removes YAML frontmatter from markdown content.
func StripHTMLTags ¶
StripHTMLTags removes HTML tags from a string.
Types ¶
type Breadcrumb ¶
type Breadcrumb struct {
Label string `json:"label"` // display label
URL string `json:"url"` // URL (empty for current page)
IsLast bool `json:"isLast"` // true if this is the current page
}
Breadcrumb represents a single breadcrumb item.
func BuildBreadcrumbs ¶
func BuildBreadcrumbs(path string) []Breadcrumb
BuildBreadcrumbs returns the breadcrumb trail as a slice. Index pages (e.g. "guides/index") produce breadcrumbs ending at the directory name ("Guides") — no "Index" crumb.
type Config ¶
type Config struct {
ContentDir string // relative to project root
Root string // absolute project root
MDConfig markdown.Config // markdown rendering config
}
Config holds configuration for scanning documentation.
type Page ¶
type Page struct {
Path string `json:"path"` // relative path like "getting-started" or "guides/advanced"
Title string `json:"title"` // from frontmatter
Order int `json:"order"` // from frontmatter, default 999
Content string `json:"content"` // rendered HTML body
Dir string `json:"dir"` // directory grouping for sidebar
Sidebar string `json:"sidebar"` // optional sidebar section override from frontmatter
SourcePath string `json:"sourcePath"` // absolute path to original .md/.mdx file
Keywords []string `json:"keywords,omitempty"` // explicit search keywords from frontmatter
CustomSidebar []SidebarItem `json:"customSidebar"` // fully custom sidebar items (from JSON in frontmatter)
}
Page represents a single documentation page.
type SearchEntry ¶
type SearchEntry struct {
Title string `json:"title"`
Path string `json:"path"`
Content string `json:"content"`
}
SearchEntry represents a search index entry.
func BuildSearchIndex ¶
func BuildSearchIndex(pages []Page) []SearchEntry
BuildSearchIndex generates a search index from documentation pages.
type SidebarItem ¶
type SidebarItem struct {
Title string `json:"title"`
URL string `json:"url"`
Active bool `json:"active"`
Children []SidebarItem `json:"children,omitempty"`
IndexURL string `json:"indexURL,omitempty"`
Collapsible bool `json:"collapsible,omitempty"`
Expanded bool `json:"expanded,omitempty"`
}
SidebarItem represents a single entry in a recursive sidebar tree. Items with Children act as expandable folder sections. Items with URL (and no Children) act as clickable links. Items with neither are plain text headers.
func BuildSidebarTree ¶
func BuildSidebarTree(pages []Page) []SidebarItem
BuildSidebarTree builds a recursive sidebar tree from pages. Pages are grouped by their directory structure — each subdirectory becomes a nested SidebarItem with Children, supporting infinite nesting.
func EnrichSidebarItems ¶
func EnrichSidebarItems(items []SidebarItem, currentPath string) []SidebarItem
EnrichSidebarItems pre-computes IndexURL, Collapsible, and Expanded fields for each sidebar item relative to the given currentPath. This allows the TSX renderer to use these values directly without function calls.
type TOCItem ¶
type TOCItem struct {
Title string `json:"title"` // displayed text
ID string `json:"id"` // anchor id
Depth int `json:"depth"` // 2 for h2, 3 for h3
}
TOCItem represents a single heading entry in the table of contents.
func ExtractTOC ¶
ExtractTOC parses rendered HTML and extracts heading structure for the TOC sidebar.