Documentation
¶
Overview ¶
Package bcontent ("base content") provides base types and functions shared by both content and the core build tool for content. This is necessary to ensure that the core build tool does not import GUI packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Page ¶
type Page struct { // Source is the filesystem that the page is stored in. Source fs.FS `toml:"-" json:"-"` // Filename is the name of the file in [Page.FS] that the content is stored in. Filename string `toml:"-" json:"-"` // Name is the user-friendly name of the page, defaulting to the // [strcase.ToSentence] of the [Page.Filename] without its extension. Name string // URL is the URL of the page relative to the root of the app, without // any leading slash. It defaults to [Page.Name] in kebab-case // (ex: "home" or "text-fields"). A blank URL ("") manually // specified in the front matter indicates that this the root page. URL string // Title is the title displayed at the top of the page. It defaults to [Page.Name]. // Note that [Page.Name] is still used for the stage title and other such things; this // is only for the actual title widget. Title string // Date is the optional date that the page was published. Date time.Time // Authors are the optional authors of the page. Authors []string // Draft indicates that the page is a draft and should not be visible on the web. Draft bool // Categories are the categories that the page belongs to. Categories []string }
Page represents the metadata for a single page of content.
func NewPage ¶
NewPage makes a new page in the given filesystem with the given filename, sets default values, and reads metadata from the front matter of the page file.
func (*Page) Defaults ¶
func (pg *Page) Defaults()
Defaults sets default values for the page based on its filename.
func (*Page) ReadContent ¶
ReadContent returns the page content with any front matter removed. It also applies [Page.categoryLinks].
func (*Page) ReadMetadata ¶
ReadMetadata reads the page metadata from the front matter of the page file, if there is any.
type PreRenderPage ¶
type PreRenderPage struct { Page // Description is the automatic page description. Description string // HTML is the pre-rendered HTML for the page. HTML string }
PreRenderPage contains the data for each page printed in JSON by a content app run with the generatehtml tag, which is then handled by the core build tool.