package main import ( "bytes" "context" "fmt" "strings" "git.dev.alexdunmow.com/block/core/blocks" ) // ManpageHeaderBlockMeta defines metadata for the man-page header block. var ManpageHeaderBlockMeta = blocks.BlockMeta{ Key: "manpage_header", Title: "Man-page Header", Description: "NAME(section) ... center ... version row, like a man-page top line", Source: "terminal", Category: blocks.CategoryLayout, } // ManpageHeaderData is the parsed content for the manpage_header block. type ManpageHeaderData struct { Name string Section int Version string // Banner is the rendered top-line text: "NAME(1) ... version". Banner string } // ManpageHeaderBlock renders the man-page top row. // Content shape: {name, section, version}. func ManpageHeaderBlock(ctx context.Context, content map[string]any) string { data := ManpageHeaderData{ Name: strings.ToUpper(getStringDefault(content, "name", "PAGE")), Section: getInt(content, "section", 1), Version: getStringDefault(content, "version", "terminal v0.1.0"), } if data.Section < 1 { data.Section = 1 } data.Banner = fmt.Sprintf("%s(%d) %s %s", data.Name, data.Section, "—", data.Version) var buf bytes.Buffer _ = manpageHeaderComponent(data).Render(ctx, &buf) return buf.String() }