Documentation ¶
Overview ¶
Package pages provides an easy way to make content-focused sites consisting of Markdown, HTML, and Cogent Core pages.
Index ¶
- Variables
- func ExampleHandler(ctx *htmlview.Context) bool
- type Page
- func (pg *Page) AppBar(tb *core.Toolbar)
- func (pg *Page) Config()
- func (t *Page) New() tree.Node
- func (t *Page) NodeType() *types.Type
- func (pg *Page) OnAdd()
- func (pg *Page) OnInit()
- func (pg *Page) OpenURL(rawURL string, addToHistory bool)
- func (t *Page) SetSource(v fs.FS) *Page
- func (t *Page) SetTooltip(v string) *Page
Constants ¶
This section is empty.
Variables ¶
var Examples = map[string]func(parent core.Widget){}
Examples are the different core examples that exist as compiled Go code that can be run in pages. The map is keyed by ID. Generated pagegen.go files add to this by finding all code blocks with language Go (must be uppercase, as that indicates that is an "exported" example).
var NumExamples = map[string]int{}
NumExamples has the number of examples per page URL.
var PageType = types.AddType(&types.Type{Name: "cogentcore.org/core/pages.Page", IDName: "page", Doc: "Page represents a content page with support for navigating\nto other pages within the same source content.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Source", Doc: "Source is the filesystem in which the content is located."}, {Name: "Context", Doc: "Context is the page's [htmlview.Context]."}, {Name: "History", Doc: "The history of URLs that have been visited. The oldest page is first."}, {Name: "HistoryIndex", Doc: "HistoryIndex is the current place we are at in the History"}, {Name: "PagePath", Doc: "PagePath is the fs path of the current page in [Page.Source]"}, {Name: "URLToPagePath", Doc: "URLToPagePath is a map between user-facing page URLs and underlying\nFS page paths."}}, Instance: &Page{}})
PageType is the types.Type for Page
Functions ¶
func ExampleHandler ¶
ExampleHandler is the htmlview handler for <pages-example> HTML elements that handles examples.
Types ¶
type Page ¶
type Page struct { core.Frame // Source is the filesystem in which the content is located. Source fs.FS // Context is the page's [htmlview.Context]. Context *htmlview.Context `set:"-"` // The history of URLs that have been visited. The oldest page is first. History []string `set:"-"` // HistoryIndex is the current place we are at in the History HistoryIndex int `set:"-"` // PagePath is the fs path of the current page in [Page.Source] PagePath string `set:"-"` // URLToPagePath is a map between user-facing page URLs and underlying // FS page paths. URLToPagePath map[string]string `set:"-"` }
Page represents a content page with support for navigating to other pages within the same source content.
func NewPage ¶
NewPage adds a new Page with the given name to the given parent: Page represents a content page with support for navigating to other pages within the same source content.
func (*Page) NodeType ¶
NodeType returns the *types.Type of Page
func (*Page) OpenURL ¶
OpenURL sets the content of the page from the given url. If the given URL has no scheme (eg: "/about"), then it sets the content of the page to the file specified by the URL. This is either the "index.md" file in the corresponding directory (eg: "/about/index.md") or the corresponding md file (eg: "/about.md"). If it has a scheme, (eg: "https://example.com"), then it opens it in the user's default browser.
func (*Page) SetSource ¶
SetSource sets the [Page.Source]: Source is the filesystem in which the content is located.
func (*Page) SetTooltip ¶
SetTooltip sets the [Page.Tooltip]