pages

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 22 Imported by: 1

Documentation

Overview

Package pages provides an easy way to make content-focused sites consisting of Markdown, HTML, and Cogent Core pages.

Index

Constants

This section is empty.

Variables

View Source
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).

View Source
var NumExamples = map[string]int{}

NumExamples has the number of examples per page URL.

View Source
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

func ExampleHandler(ctx *htmlview.Context) bool

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

func NewPage(parent tree.Node, name ...string) *Page

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) AppBar

func (pg *Page) AppBar(tb *core.Toolbar)

AppBar is the default app bar for a Page

func (*Page) Config

func (pg *Page) Config()

func (*Page) New

func (t *Page) New() tree.Node

New returns a new *Page value

func (*Page) NodeType

func (t *Page) NodeType() *types.Type

NodeType returns the *types.Type of Page

func (*Page) OnAdd added in v0.1.1

func (pg *Page) OnAdd()

func (*Page) OnInit

func (pg *Page) OnInit()

func (*Page) OpenURL

func (pg *Page) OpenURL(rawURL string, addToHistory bool)

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

func (t *Page) SetSource(v fs.FS) *Page

SetSource sets the [Page.Source]: Source is the filesystem in which the content is located.

func (*Page) SetTooltip

func (t *Page) SetTooltip(v string) *Page

SetTooltip sets the [Page.Tooltip]

Directories

Path Synopsis
examples
Package wpath handles pages paths.
Package wpath handles pages paths.

Jump to

Keyboard shortcuts

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